Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-420

Kelly Criterion Fraction

Problem

For a bet paying b-to-1 with win probability p, the Kelly fraction of wealth to stake is max(0, (b p - (1 - p)) / b).

Given p and the odds b > 0, return the fraction.

Hint

Never bet when the edge is negative.

Test cases

case 1
in: [0.6,1]
expected: 0.19999999999999996
case 2
in: [0.4,1]
expected: 0
case 3
in: [0.5,2]
expected: 0.25
Starter codePython
def kelly_criterion_fraction(p, b):
    # Your code here
    pass

3 test cases · run your code against them in the editor