]> gitweb.factorcode.org Git - factor.git/commitdiff
math.statistics: Fix out of bounds on quantiles that should return the first element.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 17 Jun 2013 14:21:45 +0000 (07:21 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 17 Jun 2013 14:21:45 +0000 (07:21 -0700)
basis/math/statistics/statistics-tests.factor
basis/math/statistics/statistics.factor

index 65d347f5ed5472ac508dd4b8b6823a3d99f8e43a..932b8ee13227868bda4537111b1a20de7d5b8382 100644 (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
index 7604940c186f06fe38ca4e50549a7c9c32b542d1..320819bd9a884dde833a7c6305e45fd8631e4dbe 100644 (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' )