]> gitweb.factorcode.org Git - factor.git/commitdiff
math.statistics: Add trimean.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 17 Jun 2013 16:55:20 +0000 (09:55 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 17 Jun 2013 17:16:28 +0000 (10:16 -0700)
basis/math/statistics/statistics-tests.factor
basis/math/statistics/statistics.factor

index 932b8ee13227868bda4537111b1a20de7d5b8382..25ef951c66475e68c8c7e0c08c0e320478e8e24d 100644 (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
index 8ef53dad556b1b0336b2aefb941402b9726f1129..493e17720a59e6f72317c1efdca0c8e5717e6789 100644 (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 )