-USING: assocs kernel math math.functions math.statistics sequences
+USING: arrays assocs kernel math math.functions math.statistics sequences
math.order tools.test math.vectors ;
FROM: math.ranges => [a,b] ;
IN: math.statistics.tests
[ 1 ] [ { 1 } mean ] unit-test
[ 0 ] [ { } mean ] unit-test
[ 3/2 ] [ { 1 2 } mean ] unit-test
-[ 0 ] [ { 0 0 0 } geometric-mean ] unit-test
+[ 0.0 ] [ { 0 0 0 } geometric-mean ] unit-test
[ t ] [ { 2 2 2 2 } geometric-mean 2.0 .0001 ~ ] unit-test
[ 1.0 ] [ { 1 1 1 } geometric-mean ] unit-test
+[ t ] [ 1000 1000 <array> geometric-mean 1000 .01 ~ ] unit-test
+[ t ] [ 100000 100000 <array> geometric-mean 100000 .01 ~ ] unit-test
[ 1/3 ] [ { 1 1 1 } harmonic-mean ] unit-test
[ 5+1/4 ] [ { 1 3 5 7 } contraharmonic-mean ] unit-test
[ 18 ] [ { 4 8 15 16 23 42 } 0 trimmed-mean ] unit-test
[ sum-of-squares ] [ length ] bi / sqrt ; inline
: geometric-mean ( seq -- x )
- [ length ] [ product ] bi nth-root ; inline
+ [ [ log ] map-sum ] [ length ] bi /f e^ ; inline
: harmonic-mean ( seq -- x )
[ recip ] map-sum recip ; inline