Showing posts with label Kelly. Show all posts
Showing posts with label Kelly. Show all posts

Tuesday, February 6, 2007

Kelly for the cowardly

Kelly staking is - as we've seen before - the mathematically optimal way to grow your bankroll. It has one glaring problem, though: it's horrifically volatile. Let's imagine we make 100 bets which we know are 50-50 shots but the bookies insist on pricing at 2.10. Our Kelly stake is (po-1)/(o-1) = 4.55%.

Now, when we win, we tend to win big - about a quarter of the time, we'd get 53 or more correct. That would net us at least a 49% profit. The flip-side of that is, a quarter of the time we get 46 or fewer and lose a quarter of our bankroll. There's a one in twenty chance that we'll lose half of our bankroll (although one in ten that we'll double it). With bigger edges or shorter odds, the fluctuations can be terrifying.

Is there a way to reduce them? Well, obviously, if you don't bet so much, your bankroll is steadier. But let's say you're still pretty greedy, and want to maximise your worst plausible outcome.

How do you even define that? Well, given that we're looking at a binomial distribution, we can use stats to help us. If we look at N identical bets with probability p, we know that 97.7% of the time* we'll win at least Wmin = Np - 2 sqrt(Np(1-p)) of them. Bumping up the 2 to 3 gives us 99.87% confidence.

Whatever value we choose - I'm happy enough with two - outlines our worst plausible set of results over N trials**. We can then calculate our worst plausible outcome, which is B0 (1 + k(o-1))Wmin(1 - k)(N-Wmin).

The trick now is to maximise this with respect to each k. It turns out, if we define p* as Wmin/N, that our optimal Kelly stake in this sense is (p*o-1)/(o-1). And if it's less than zero, we don't bet.

This is quite restrictive - in the case above, with N = 100 we simply wouldn't bet - p* is 40%, far too low to allow us to meet our minimum. N = 1000 isn't that much better - p* = 46.8%, where we need 47.6%. N = 2500 is just about enough.

Here are the results of running 2500 bets 1000 times over (using the two staking patterns on the same events):

Pure Kelly Modified
Stake 4.55% 0.73%
AROI*** 26.07% 3.81%
SD 64.52% 23.58%
Worst -79.85% -11.44%


So, on average, Kelly outperforms the modified version by some way - but at the cost of much higher risk. The modified stakes 'guarantee' that the lowest plausible value is as large as possible.

It is possible to make up the discrepancy to a fair degree by increasing N, because the larger N is, the closer p* is to p (the square root term ends up getting very small).

Modified Kelly staking is worthwhile for bets with sufficiently large edges, or over sufficiently long runs. If you plan to make only 100 bets, you would need odds of at least 2.5 on a 50-50 shot before the modified stakes allowed you to bet.

I just typed bed, which is probably a Freudian slip. It's getting late.

* Look it up in a normal distribution table.

** We needn't assume the bets are identical. In general, we can replace Np with sum(p) and the bit inside the square root would be sum( p(1-p) ). But that complicates things a bit more than we need for the proof of concept.

*** Average Return on Investment

Sunday, February 4, 2007

Optimal staking subject to constraints

This came from a post in Punter's Paradise by The Dark Arts.

It's Sunday night, you've got 5 value calls on that night's NFL games. Let's say you can get 10/11 (1.909) but you make them 55% chances. However, they are each simultaneous kick off times.

What's your stake?

(BTW,I don't know the answer).

tda.


The maths for this is a mess, using partial derivatives and Lagrangian multipliers, but the stake sizes that maximise your bankroll long-term can be calculated.

Here's the situation: you make n simultaneous bets of ki of your bankroll B0 at oi, each of which has probability pi of occurring (for i = 1..n). The expected return Ei for each bet is

Ei = B0 (1 + ki (oi -1)^(pi) (1-ki)^(1-pi). (1)

Your expected bankroll B after the results come in is

B(k) = sum(i=1..n) Ei. (2)

However, you're subject to the constraint that you can't bet more than your entire bankroll:

g(k) := sum(i=1..n) ki <= 1. (3)

This is a problem for Lagrangian multipliers. We want to maximise B (Eq 2) subject to the constraint (Eq 3). We then want to solve for:

∂B/∂ki + λ ∂g/∂ki (4), for all i, and
g(k) <= 1 (5)

The derivation is a mess, with
∂B/∂ki = B0 (1 + ki (oi-1))^(pi-1) (1-ki)^(-pi) (pioi-1 - ki(oi-1)). (6)

I doubt there's a closed-form solution for this, but trial and error works - let's try a complicated case first, with two great-looking bets:

Bet .p. .o.. .k..
.1. 0.9 1.50 0.70
.2. 0.8 2.50 0.67


Our Kelly stakes add to 1.37 bankrolls and we only have one! So what's the best solution? Obviously, if we can't get as much on as we want, we should bet as much as we can, so we have a strict constraint - the <= is an equals sign. The derivatives of g are all one, so we're left with λ = ∂B/∂ki for all i - meaning that all the derivatives of B are the same. In this case, the only solution is for λ ~ 0.225, giving stakes of 41.8% and 58.2%.

The upshot of all this is that the optimal staking strategy is when the partial derivatives ∂B/∂ki are equal and the kis sum to at most one. There are two scenarios: first, if the Kelly stakes generated the usual way sum to less than 1, they're optimal. This is the case in TDA's question, which I'll get back to in a minute. If not, you're going to need to get your Excel solver working hard to satisfy the constraints. Or write some code.

In TDA's question, we had p=0.55, o=1.919 and n = 5. The optimal stake on each is 0.055, making a total stake of 0.275.

Thursday, February 1, 2007

From the postbag: Doubles

Of course, Splittter is the only one writing to me at the moment, which makes me feel a bit like Willie Thorne in the Fantasy Football League sketches. Anyway, here is his wisdom:

Your post on doubles has been bugging me since I read it basically because the accepted gambling wisdom is simply "don't do doubles", full stop, no exceptions... yet your maths looked correct.

I had a sneaking suspicion that it had to do with your bet size relative to your bankroll, and that hidden in the double is the fact that you're essentially sticking an amount larger than your actual stake on the 'second' outcome.

So, to test that theory I imagined the following:

There are two bets for which you'll get 3.00: event 1 you reckon will come in 37%, event 2 35%, both clear value bets.


He goes on to analyse the situation in excruciating detail. As I refuse to be out-mathsed by anyone, let alone Splittter, I'll do the same but more clearly - and reach a slightly different conclusion. His experiment suggests Kelly staking.

With Kelly staking, you would place a fraction k = p - (1-p)/(o-1) of your bankroll on each bet. Your expected return is p(kB(o-1)) - (1-p)(kB) = Bk(po-1)

Betting singles, your Kelly stake on the first game is 5.5% of bankroll; on the second, 2.5%. The outcomes are as follows:

Win-win: (12.95%) +16.50%
Win-lose: (24.05%) + 8.23%
Lose-win: (22.05%) - 0.78%
Lose-lose: (40.95%) - 7.86%

The weighted average of these - trust me - is 0.73%.

By contrast, if you bet the double, your Kelly stake is 2.07% of bankroll, and your outcomes are:

Win-win: (12.95%) +16.5%
Any other: (87.05%) - 2.1%

So, on average, you come out 0.34% ahead. So far, so good for the singles. However, let's examine the bets in terms of risk vs. reward:

Expected risk for two singles: 6.99%
Expected return: 0.73%
Value for singles: 10.44%

Risk for double: 2.07%
Expected return: 0.34%
Value for double: 16.42%

You might argue that we're not comparing apples for apples - that if we're betting singles, we're forced to make the second bet even if the first fails. However, if we don't make the second bet, we do even worse - as you'd expect, failing to make a value bet lowers your expected return (in this case, to 0.66%). The risk in that case is fixed at 5.5%, making the value 12.00% even.

How about the order of the bets? In fact, it doesn't make a difference to the expected return. It does make a difference to your expected risk, though, which drops to 6.26%. That makes the value 11.66% - still lower than the double. Without the second bet if the first loses, the expected return falls to 0.34%, with a risk of 2.5%, making the value 13.59%.

My correspondent challenges me to prove things in general. I scoff, mainly because I ought to do some work. I may leave that for a later post.

All of which seems to show that a double on two value bets gives better value than two singles. The singles give a higher expected value, but at the cost of an increase in risk which reduces the value below the double's.

Sunday, January 28, 2007

Kelly staking

Mathematician John Kelly came up with a system for staking which maximises your expected return over the long term. This is going to be a load of maths, so look away now if you're not interested.

Assuming you bet a proportion k of your bankroll each time at odds o, after you win W and lose L bets, you have B' = B [(1 + k(o-1))W (1 - k)L]. We want to find the maximum of this, so we take the derivative and set it to 0:
dB'/dk = W(o-1)(1-k) - L(1 + k(o-1)) = 0.

Or, W(o-1)(1-k) = L(1 + k(o-1)). Since over the long term, W/L -> p/(1-p) (see earlier post on the Law of Large Numbers), we can substitute in to get:
p(o-1)(1-k) = (1-p)(1 + k(o-1)). A little algebra then gives us:
k = p - (p-1)/(o-1), the Kelly Staking formula.

That means, if you assess the probability of the outcome to be 50% and the odds are 2.10, you should stake 0.5 - 0.5 / (1.1) ~ 0.5 - 0.45 = 0.05: a twentieth of your balance.

That's a big gamble. After losing a few consecutive bets, your bankroll of GBP1000 would have dwindled like this:
1. Bankroll: 1000.00 Bet: 50.00
2. Bankroll: 950.00 Bet: 47.50
3. Bankroll: 902.50 Bet: 45.13
4. Bankroll: 857.37 Bet: 40.72
5. Bankroll: 816.65

In four bets, you've lost nearly a fifth of your bankroll! On the other hand, if you'd won, you'd be laughing:
1. Bankroll: 1000.00 Bet 50.00
2. Bankroll: 1055.00 Bet 52.75
3. Bankroll: 1103.03 Bet 55.65
4. Bankroll: 1174.24 Bet 58.71
5. Bankroll: 1238.82

And you're up almost 24%. Kelly staking is a wild ride. As long as your value calculations are right, you'll end up way ahead in the long run*. Occasionally you'll lag at the wrong end of the binomial distribution and look like you're way behind.

Some gamblers choose to use a slightly less volatile system called fractional Kelly, in which they split their bankroll into (say) five separate bankrolls and use only one for Kelly calculations. That dampens the volatility a bit, but does make for smaller gains when you're winning.

So long as your value estimation is correct and the law of large numbers takes hold quickly enough - and you can stand the wild fluctuations in your bankroll - Kelly staking is the most profitable system known to mathematics. Use it wisely.

* In the above situation, you'd need about 1800 bets to be 95% sure of breaking even or better.