All problems
Kelly Fraction
Problem
Compute the Kelly fraction for a bet with win probability p and payoff odds b: f = (p * b - (1 - p)) / b.
Return 0.0 when b is not positive. A negative result means the bet has no edge.
Hint
The Kelly fraction maximizes expected logarithmic growth.
Test cases
case 1
in: [0.6,2]
expected: 0.39999999999999997
case 2
in: [0.5,1]
expected: 0
case 3
in: [0.4,2]
expected: 0.10000000000000003
case 4
in: [0.6,0]
expected: 0
Starter codePython
def kelly_fraction(p, b):
# Your code here
pass4 test cases · run your code against them in the editor