Git Product home page Git Product logo

kelly-criterion-simulation's Introduction

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));

kelly-criterion-simulation's People

Contributors

reinhardlenz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.