# What is the Perfect Bet Size?

The Kelly Criterion was developed by John Kelly at Bell labs in the 1950’s. He took the work that Claud Shannon had done on information theory and applied it to betting. It optimizes the median outcome potential for a given situation. In addition to gambling it has applications in portfolio management as well.

Kelly focused on the median outcome rather than the mean outcome because the distribution skew causes the mean value to be higher than what is actually experienced on average. I did a previous article that digs into this deeper by analyzing coin flips.

This article takes a look at how the formula works through a derivation of it, as well as a walk through an excel template to apply the Kelly Criterion.

# Deep Dive on the Formula

Note: You can skip this section if you aren’t as interested in the nitty gritty of how the formula works.

The formula starts with the geometric mean since it is more analogous to the median outcome. It is similar to the arithmetic mean, but instead of adding you multiple together each item. To start with, lets look at a situation with two outcomes. We use *f* to be the fraction of our bankroll/portfolio to allocate towards the wager/position. The returns of the outcome can be represented by *a* and *b* (-1 is a complete loss of the bet and 0.1 would be a 10% gain)*.* The probabilities of each outcome are *Pa* and *Pb*, and it is assumed that both probabilities add to 100% (no other outcomes are possible).

To maximize the expected outcome we need to take the derivative and set it equal to 0. This gets easier if we take the logarithm of both sides of the equation first. This allows us to break the multiplication up into adding the two terms together as well as bringing the exponents (probabilities) down as a scaler.

Taking the derivative of a log function results in the derivative of the inside of the function divided by the function itself.

If we multiple both the top and bottom by (1+fb)(1+fa) we get rid of the fractions. We can then rearrange by multiplying out everything and pulling out the f.

If we utilize the fact that the probabilities for the two outcomes must sum to 1 then we can simplify as below.

This formula is much simpler than the original form. It also allows us to calculate the optimal bet size using only the rates of return and probability of each event occurring.

This problem becomes much trickier as you add outcomes. The reason for this is when you multiply by the denominators you end up with higher orders of f. For instance, if we add in a third event we end up with an f² term. This is still manageable with the quadratic formula, but higher orders are problematic.

# Application

To turn the Kelly criterion into something more practical I made an excel document. I considered doing it in python, but I felt the application would be more accessible in excel. The GitHub link to the file is here.

The file includes an area for you to input probabilities and rates of return for up to 3 events. In the example below I evaluated a stock. I assume a 1% probability of a complete loss, and a roughly 50/50 probability of a 20% gain or 10% loss. While these probabilities and returns are just estimates, the Kelly criterion can help you think about how risky the position is and how much of your funds you should allocate to it.

The formulas we derived above are used to calculate the optimal or Kelly bet size as well as the expected outcome. The excel will flag if the outcome probabilities don’t sum to 100%. Additionally, it will plot the expected returns of various sizes. This lets you see how the recommended bet size compares against the spectrum of possible bets.

A half Kelly bet is calculated because betting the full Kelly bet can tend to lead to some wild swings in your bank roll. Based on the example stock, the half Kelly portfolio allocation would be 36% of the total portfolio.

Hopefully, the explanation of the formula along with excel tool will be useful, when you considering how much to bet or how you could allocate various stocks within your portfolio.