]> gitweb.factorcode.org Git - factor.git/commitdiff
math.statistics: Handle some edge cases.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 17 Jun 2013 17:15:35 +0000 (10:15 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 17 Jun 2013 17:16:28 +0000 (10:16 -0700)
Remove two unused parameters.

basis/math/statistics/statistics.factor

index 493e17720a59e6f72317c1efdca0c8e5717e6789..e50c7006f97124f177a9ed90802162d935b28427 100644 (file)
@@ -158,21 +158,21 @@ PRIVATE>
 ! could subtract 1 from a
 
 : quantile-x ( a b N q -- x )
-    [ + ] dip * + 1 [-] ; inline
+    [ + ] dip * + 1 - ; inline
 
 ! 2+1/4 frac is 1/4
 : frac ( x -- x' )
     >fraction [ /mod nip ] keep / ; inline
 
-:: quantile-indices ( seq qs a b c d -- seq )
+:: quantile-indices ( seq qs a b -- seq )
     qs [ [ a b seq length ] dip quantile-x ] map ;
 
 :: qabcd ( y-floor y-ceiling x c d -- qabcd )
     y-floor y-ceiling y-floor - c d x frac * + * + ;
 
 :: quantile-abcd ( seq qs a b c d -- quantile )
-    seq qs a b c d quantile-indices :> indices
-    indices [ [ floor ] [ ceiling ] bi 2array ] map
+    seq qs a b quantile-indices :> indices
+    indices [ [ floor 0 max ] [ ceiling seq length 1 - min ] bi 2array ] map
     concat :> index-pairs
 
     seq index-pairs kth-smallests