math.statistics: Fix out of bounds on quantiles that should return the first element.

db4
Doug Coleman 2013-06-17 07:21:45 -07:00
parent 6c6664b0b8
commit 77abc31e3b
2 changed files with 7 additions and 1 deletions

View File

@ -224,3 +224,9 @@ IN: math.statistics.tests
H{ { 0 V{ 0 3 6 9 } } { 1 V{ 1 4 7 10 } } { 2 V{ 2 5 8 } } }
}
[ 600 610 [a,b] [ 3 mod ] collect-index-by ] unit-test
{ { 1 } } [
{ 1 2 3 4 5 10 21 12 12 12 12203 3403 030 3022 2 2 }
{ 1/1000 } quantile5
] unit-test

View File

@ -158,7 +158,7 @@ PRIVATE>
! could subtract 1 from a
: quantile-x ( a b N q -- x )
[ + ] dip * + 1 - ; inline
[ + ] dip * + 1 - 0 max ; inline
! 2+1/4 frac is 1/4
: frac ( x -- x' )