math.extras: adding the Kelly criterion.

db4
John Benediktsson 2015-04-01 21:34:54 -07:00
parent ea2547aae3
commit a4c0ae98c5
2 changed files with 7 additions and 0 deletions

View File

@ -157,3 +157,7 @@ IN: math.extras.test
} [ } [
30 [1,b] [ mobius ] map 30 [1,b] [ mobius ] map
] unit-test ] unit-test
{ 0.2 } [ 0.6 1 kelly ] unit-test
{ 0.0 } [ 0.5 1 kelly ] unit-test
{ -0.2 } [ 0.4 1 kelly ] unit-test

View File

@ -322,3 +322,6 @@ M: iota-tuple sum-cubes sum sq ;
dup [ 1 > ] any? dup [ 1 > ] any?
[ drop 0 ] [ length even? 1 -1 ? ] if [ drop 0 ] [ length even? 1 -1 ? ] if
] if-empty ; ] if-empty ;
: kelly ( winning-probability odds -- fraction )
[ 1 + * 1 - ] [ / ] bi ;