Skip to content

a web page written in php, which allows user to set start criteria and then let the web page run and show, to what it leads

Notifications You must be signed in to change notification settings

ReinhardLenz/Kelly-criterion-simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Kelly-criterion-simulation a web page written in php, which allows user to "simulate" a casino game. let the web page run and show, to what it leads.

The background: Why it doesn't pay to put all your money on one horse?

In an experiment a group of persons were asked to participate at a lottery, in which the participiants can win and then double the wage in 60% of the cases, but in 40% of the case they lose the wagered part of their capital. For a start each participant was given 20 Dollars and then he had 30 minutes time to play the game. Theoretically, in this 30 minutes one could bet 300 times.

casino

The result of this experiment? At the end, a third of the participants had less then at the start of the experiment, even more, 28 percent of the participants had lost all the capital and went bancrupt. Only 21 percent of the participants achieved the required required maximum of 250 Dollars, which should have been achieved at correct application of the Kelly criterium. Accordingly, the average payout of 91 Dollars was significantly below the expected value of 250 Dollars. 18 persons of the 61 participants of the experiment even put all their eggs in one basket, whereby the probability of a total loss went up to 40 percent. Whereas, when using the Kelly formula, the probability of a total loss is almost zero percent.

What would have been the optimum strategy, when using the Kelly criteria? What if, as in the described experiment, the probability of winning would be 60%, and the win-loss ratio would be 1 (Meaning, in case of winning the bet, the stake is doubled)? In this example, the percentage of the capital, which should be risked (wagered) should be 20 percent of the presently available money. kelly-formular

If you risk, as in this example, more then 20% of you money for a lottery, in the long run there is a risk to loose all your capital - even if the statistical chances are in your favor. On the other hand the average gain of a participant would be 4% per game round.

This is the page generated by the php code:

#kelly-screenshot

Inputs Win probability: 50% means half of the games win. In a game of dice, the probability to win is 16% Given odds on the event: 1=stake is doubled, 2= stake is multiplied by three, etc. Start capital of the game: That's everything you have. How much money do you have? (like 25 Dollars for a child, but if you are a millionare, then 1 Million!) Fraction of the of the present bankroll to be wagered: Think about it like it weren't a game, really, if you put 100% and you loose the first game, then you are a beggar! No continuation after the first step. That's really the idea of this simulation, you should keep clearly in front of your eyes, that a wrong decision with high risk, it leads to total and utter bancrupcy.

Inside the code: The input is Win $probability, Odds of the event $odds, start capital $start_cap and fraction of bankroll to be wagered $fraction_wagered.

The program generates the array variables for each stage of the game $winloose=range(1,20,1) etc.

The radom win or loose is generated by the random event$winloose[$n]=rand(0,100) and then it is decided, whether it is loose or win, by the if statement if($winloose[$n]<$probability)

In the following, the capital of each stage of the game is calculated.

At last, the 2D column chart is created

where the height of the columns is calculated depending on array variable$capital[$n] $height[$n]=strval(round(300*$capital[$n]/$max_height_corresponds,PHP_ROUND_HALF_DOWN));

About

a web page written in php, which allows user to set start criteria and then let the web page run and show, to what it leads

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages