math.statistics: adding contraharmonic-mean.

db4
John Benediktsson 2012-05-04 14:43:29 -07:00
parent 4339b14d77
commit 87686a9a31
2 changed files with 4 additions and 0 deletions

View File

@ -8,6 +8,7 @@ IN: math.statistics.tests
[ t ] [ { 2 2 2 2 } geometric-mean 2.0 .0001 ~ ] unit-test
[ 1.0 ] [ { 1 1 1 } geometric-mean ] unit-test
[ 1/3 ] [ { 1 1 1 } harmonic-mean ] unit-test
[ 5+1/4 ] [ { 1 3 5 7 } contraharmonic-mean ] unit-test
[ 0 ] [ { 1 } range ] unit-test
[ 89 ] [ { 1 2 30 90 } range ] unit-test

View File

@ -14,6 +14,9 @@ IN: math.statistics
: harmonic-mean ( seq -- x )
[ recip ] map-sum recip ;
: contraharmonic-mean ( seq -- x )
[ [ sq ] map-sum ] [ sum ] bi / ;
<PRIVATE
:: ((kth-object)) ( seq k nth-quot exchange-quot quot: ( x y -- ? ) -- elt )