Open Side Menu Go to the Top
Register
Please restore my sanity (kelly criterion) Please restore my sanity (kelly criterion)

01-13-2019 , 03:20 PM
There is an advantageous bet that you can repeat forever. If you bet x amount, one of 3 things can happen:

a) Win w*x with probability p=.59375, where w = .42174
b) Lose L*x with probability q=.395833, where L = .272
c) Lose x with probability r=.010417

I tried to answer this: what % (call it f) of your bankroll should you wager each time to maximize expected growth (or median future wealth)?

My attempt:

g = (1+.42174f).59375 * (1-.272f).395833 * (1-f).010417

Numeric optimization in R:
Code:
kelly = function(p,w) {
  fn = function(f,p,w) prod((1+f*w)^p)
  optimize(fn,p=p,w=w,lower=0,upper=1,maximum=TRUE,tol=.Machine$double.eps)$maximum
}
w <- c(.42174, -.272, -1)
p <- c(.59375, .395833, .010417)
paste(kelly(p,w))
Result: 0.793143075975138

My own optimization algorithm in Julia:
Code:
@fastmath function kelopti(p::Float64, r::Float64, w::Float64, L::Float64, firstep=1/16)
    q = 1-p-r
    f, g, step, upper = 0.0, 0.0, firstep, 1.0
    while(true)
        newf = f+step
        while(true)
            (0 ≤ newf ≤ upper) ? break : step/=2
            newf = f+step
        end
        newg = (1+w*f)^p * (1-L*f)^q * (1-f)^r
        if newg ≤ g
            step /= -2
            step==0.0 && return f
        end
        f = newf
        g = newg
    end
end
kelopti(.59375, .010417, .42174, .272) = 0.7931431029303357

But f can't be >p, can it? So I tried an analytical solution. I took the derivative of ln(g), set it to 0 and used Sagemath to solve for f:

f = {Lpw + Lp + Lqw + w - L - qw - √[(qw + L - Lp - Lpw - Lqw - w)² - 4Lw(p + q + pw - Lq - 1)] } / (2Lw)

which gives an answer of 0.7931430966114893

Lastly, I tried a random simulation but same result.

It appears that all roads point to f>p, but how in the hell can that be? I can't bring myself to believe it, but I also don't know where my mistake is. My guess would be the growth equation, but if so, I have a fundamental misunderstanding of growth.

Here's why I refuse to believe f>p. When there are only 2 possible outcomes, the kelly equation is f = p - (1-p)/w. Here, if you remove Outcome C, observe that the kelly stake will be smaller than p:

p' = p/(p+q) ≈ .6
w' = w/L ≈ 1.5505
f' = .6 - .4/1.5505 = .342

The effect of inserting a 3rd outcome worse than B should be to decrease f, not increase it.

Can someone explain what's going on? Tyvm
Please restore my sanity (kelly criterion) Quote
01-15-2019 , 11:31 AM
Not an expert on the topic by any mean, but the main point I guess it's that you rarely lose your entire bet. The f<p condition mostly holds if you lose f when you lose. Here, assuming that you bet f = 0.7931, you are actually risking f*L, which is about 0.21, way less than p.
Please restore my sanity (kelly criterion) Quote
01-16-2019 , 04:04 PM
Quote:
Originally Posted by heehaww
So I tried an analytical solution
It's really easy to use Wolfram Alpha for this:

Solve[D[0.59375*Log[1+0.42174*x]+0.395833*Log[1-0.272*x]+0.010417*Log[1-x],x]==0,x]

(it sometimes gets confused if you try to add too many outcomes though... if it does, then try to bunch up the expression and remove all unnecessary whitespace between terms)

Quote:
But f can't be >p, can it?
f can even be >1! This indicates that you should use leverage (this isn't common for gambling-related use of Kelly, but for the quant-related use it is, eg: http://epchan.blogspot.com/2006/10/h...d-you-use.html).

(but because you added the 3rd outcome which is a "total loss" the value will obviously never go above 1 for this case)

BUT:
Quote:
Here's why I refuse to believe f>p. When there are only 2 possible outcomes, the kelly equation is f = p - (1-p)/w. Here, if you remove Outcome C, observe that the kelly stake will be smaller than p:

p' = p/(p+q) ≈ .6
w' = w/L ≈ 1.5505
f' = .6 - .4/1.5505 = .342

The effect of inserting a 3rd outcome worse than B should be to decrease f, not increase it.
I'm not quite sure what you've worked out here, but if you just remove the 3rd "total loss" outcome, re-normalise the remaining probabilities and then use the same utilities, you get an example where use of leverage is optimal:

Solve[D[0.6*Log[1+0.42174*x]+0.4*Log[1-0.272*x],x]==0,x] = ~1.25743

Juk
Please restore my sanity (kelly criterion) Quote
01-17-2019 , 07:29 AM
I came on here to post what I think is the explanation, and it turns out Nick already said it.

It seems instead of setting the unit to the largest possible loss, I should set it to the most probable loss.

When I do that, the long formula and my julia optimization both get 21.5734 %

(which is the same as .272 * .79314)

I'm sure that's much closer to the real answer, but I suspect the real answer has to weigh both perspectives. Maybe the real answer is simply the arithmetic weighted avg of both, 23.054 %

@juk - I don't have time right now to really process your post. I skimmed it and I'm skeptical, but I'll give it a proper read later with an open mind.

Thanks to both for responding
Please restore my sanity (kelly criterion) Quote
01-17-2019 , 07:57 AM
Quote:
Originally Posted by heehaww
@juk - I don't have time right now to really process your post. I skimmed it and I'm skeptical, but I'll give it a proper read later with an open mind.
This blog post goes into more detail about the use of kelly for asset allocation and leverage:

http://epchan.blogspot.com/2014/08/k...portfolio.html

Juk
Please restore my sanity (kelly criterion) Quote
01-18-2019 , 10:22 AM
@juk - thanks I'll give that a read soon. Still short on time because I'm traveling.

Quote:
Originally Posted by me
It seems instead of setting the unit to the largest possible loss, I should set it to the most probable smallest loss.
FMP, or keep using the largest loss but then multiply the f by the smallest loss.

Quote:
I'm sure that's much closer to the real answer, but I suspect the real answer has to weigh both perspectives. Maybe the real answer is simply the arithmetic weighted avg of both, 23.054 %
No, I think I get it now: both f's were correct but I misinterpreted the larger one. They actually tell the same thing, as was demonstrated earlier. The largest f applies when the smallest loss is counted as one unit, and the smallest f applies when the the largest loss is counted as one unit. Either way, we want our bet size to be such that the largest possible loss is 21.5% of our bankroll.

I've extended this to 4 outcomes and it's the same thing.

Oh and my kelopti() function needs the following line:
Code:
...
(newf==upper || newf==0.0) && return newf
f = newf
g = newg
Please restore my sanity (kelly criterion) Quote
01-21-2019 , 03:00 PM
No no no, my previous two posts were wrong. 79% of our bankroll is right because most of the losses are less than one unit. When I removed the 3rd outcome I also increased the unit for the more-probable loss, which I shouldn't have done because that made it a different problem altogether. And if the win amount is 1 and the loss L is smaller than 1, the two-outcome formula becomes f = p/L - q, so even with 2 outcomes f can be >p (and indeed >1 as well). Nothing about this is strange, I simply confused myself.

Thanks guys
Please restore my sanity (kelly criterion) Quote
01-22-2019 , 08:10 PM
Quote:
Originally Posted by jukofyork
It's really easy to use Wolfram Alpha for this:
It's just as easy to use Sagemath's server - https://sagecell.sagemath.org/

Unlike WA, it has no limitations (such as computation time or character limit), because it's free and open source if you want to install it.
Please restore my sanity (kelly criterion) Quote

      
m