casino_simulation, a Python code which simulates a casino game that gives you 20% of your bet for heads, and only takes 17% for tails. How much will you end up winning?

The code allows the user to simulate many repeated rounds of the game, so that a statistical analysis can be made.


The computer code and data files described and made available on this web page are distributed under the MIT license


casino_simulation is available in a MATLAB version and an Octave version and a Python version.

Related Data and codes:

dueling_idiots, a Python code which carries out the probability simulations described in "Dueling Idiots", by Paul Nahin;

matlab_simulation, a Python code which uses simulation to study card games, contests, and other processes which have a random element. Usually, the purpose is to try to predict the average behavior of the system over many trials.


  1. Bruce Boghosian,
    The Inescapable Casino,
    Scientific American,
    November 2019, pages 70-77.

Source Code:

Last revised on 28 August 2023.