math.statistics: Add trimean.

db4
Doug Coleman 2013-06-17 09:55:20 -07:00
parent cfb44999a1
commit 49c0b12b33
2 changed files with 5 additions and 0 deletions

View File

@ -230,3 +230,5 @@ IN: math.statistics.tests
{ 1 2 3 4 5 10 21 12 12 12 12203 3403 030 3022 2 2 }
{ 1/1000 } quantile5
] unit-test
{ 15+1/2 } [ { 4 8 15 16 23 42 } trimean ] unit-test

View File

@ -205,6 +205,9 @@ PRIVATE>
: quartile ( seq -- seq' )
{ 1/4 1/2 3/4 } quantile5 ;
: trimean ( seq -- x )
quartile first3 [ 2 * ] dip + + 4 / ;
<PRIVATE
: (sequence>assoc) ( seq map-quot insert-quot assoc -- assoc )