Simulation of Simple Gambling and Kelly’s Criterion

Many people would dream to go to Las Vegas, or buying lotteries, thinking one day, their life can be changed entirely by gambling. Is it true? What’re the chances they can pull it off? 

A simple simulation of flipping coins in Python gives good answer without risking real money. Assuming there are 10 people all start from $10, setting the number of rounds to be 100, 1000, 100000 by running the below script.

 
round_num = 100
person_num = 10
for person in range(1,person_num+1):
gambling_money = 10
for r in range(1,round_num+1):
coin = random.randint(0, 1) if coin == 0 :
gambling_money = gambling_money + 1
elif coin == 1 :
gambling_money = gambling_money – 1
if gambling_money == 0 :
sample_list.append([person,r,gambling_money])
break
else:
pass
sample_list.append([person,r,gambling_money])

if coin == 0 :
gambling_money = gambling_money + 1
elif coin == 1 :
gambling_money = gambling_money – 1
if gambling_money == 0 :
sample_list.append([person,r,gambling_money])
break
else:
pass
sample_list.append([person,r,gambling_money])

sample_data1 = pd.DataFrame(sample_list,columns=[‘person’,’round’,’gambling_money’])

It’s interesting to see that when the set of rounds are small as 100, there could be quite a lot of winners, while the more times they play, almost all of them will end up to be losers.

 

Betting against the house, usually they would charge 2% commission, so if we simulate the game with that taken into consideration and play it numerous times:


gambling_money_dealer = 0
gambling_money_player = 0
for i in range(1,100000+1):
coin = random.randint(0, 1)
if coin == 0 :
gambling_money_player = gambling_money_player + 0.98
gambling_money_dealer = gambling_money_dealer – 0.98
elif coin == 1 :
gambling_money_player = gambling_money_player – 1
gambling_money_dealer = gambling_money_dealer + 1
sample_list.append([i,gambling_money_dealer,gambling_money_player])

sample_data6 = pd.DataFrame(sample_list,columns=[’round’,’dealer’,’player’])

Eventually, all players end up losing all. 

However, in investment world, the gambling is not as simplistic as just throwing the dice. People usually have some good judgement in terms of the winning/losing probability, then the questions comes how much money out of their total capital should they put into the bet for how many times. 

Kelly’s Criterion is set to solve this problem:

</p>
<!-- /wp:paragraph -->

<!-- wp:quote -->
<blockquote class="wp-block-quote"><p>from sympy import *<br>
      x,b,p = symbols('x b p')<br>
      y = p<em>log(1+b</em>x) + (1-p)*log(1-x)<br>
      solve(diff(y,x), x)</p><cite>


Reaching the formula (citing from wiki):

Leading to the formula:

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.