Skip to content

Instantly share code, notes, and snippets.

@jaimezorno
Created March 24, 2020 17:15
Show Gist options
  • Select an option

  • Save jaimezorno/5011e94ddf710b321608f343599eab49 to your computer and use it in GitHub Desktop.

Select an option

Save jaimezorno/5011e94ddf710b321608f343599eab49 to your computer and use it in GitHub Desktop.

Revisions

  1. jaimezorno created this gist Mar 24, 2020.
    134 changes: 134 additions & 0 deletions Roulette Simulation.ipynb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,134 @@
    {
    "cells": [
    {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
    "# Roulette Simulation"
    ]
    },
    {
    "cell_type": "code",
    "execution_count": 32,
    "metadata": {},
    "outputs": [],
    "source": [
    "import numpy as np"
    ]
    },
    {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
    "# Definition of simulation function"
    ]
    },
    {
    "cell_type": "code",
    "execution_count": 64,
    "metadata": {},
    "outputs": [],
    "source": [
    "def roulette_simul(number,bet, n_simulations):\n",
    " for i in range(3):\n",
    " return_count = 0\n",
    " count = 0\n",
    " for i in range(n_simulations):\n",
    " s = np.random.randint(1,37)\n",
    " if s == number:\n",
    " count = count + 1\n",
    "\n",
    " return_count = -1*n_simulations + count*36 \n",
    " expected_return = return_count/n_simulations\n",
    " print(\"The expected return of betting at number {}, {} times is : {}% \".format(number,n_simulations,np.round(expected_return*100,2)))"
    ]
    },
    {
    "cell_type": "markdown",
    "metadata": {},
    "source": [
    "# Simulation"
    ]
    },
    {
    "cell_type": "code",
    "execution_count": 68,
    "metadata": {},
    "outputs": [
    {
    "name": "stdout",
    "output_type": "stream",
    "text": [
    "The expected return of betting at number 7, 2 times is : -100.0% \n",
    "The expected return of betting at number 7, 2 times is : -100.0% \n",
    "The expected return of betting at number 7, 2 times is : -100.0% \n",
    "\n",
    "\n",
    "The expected return of betting at number 7, 5 times is : -100.0% \n",
    "The expected return of betting at number 7, 5 times is : -100.0% \n",
    "The expected return of betting at number 7, 5 times is : -100.0% \n",
    "\n",
    "\n",
    "The expected return of betting at number 7, 10 times is : -100.0% \n",
    "The expected return of betting at number 7, 10 times is : -100.0% \n",
    "The expected return of betting at number 7, 10 times is : 260.0% \n",
    "\n",
    "\n",
    "The expected return of betting at number 7, 20 times is : 80.0% \n",
    "The expected return of betting at number 7, 20 times is : 80.0% \n",
    "The expected return of betting at number 7, 20 times is : -100.0% \n",
    "\n",
    "\n",
    "The expected return of betting at number 7, 100 times is : -28.0% \n",
    "The expected return of betting at number 7, 100 times is : 8.0% \n",
    "The expected return of betting at number 7, 100 times is : 8.0% \n",
    "\n",
    "\n",
    "The expected return of betting at number 7, 1000 times is : 8.0% \n",
    "The expected return of betting at number 7, 1000 times is : 15.2% \n",
    "The expected return of betting at number 7, 1000 times is : -31.6% \n",
    "\n",
    "\n",
    "The expected return of betting at number 7, 10000 times is : 1.52% \n",
    "The expected return of betting at number 7, 10000 times is : 2.6% \n",
    "The expected return of betting at number 7, 10000 times is : 0.8% \n",
    "\n",
    "\n",
    "The expected return of betting at number 7, 1000000 times is : -0.28% \n",
    "The expected return of betting at number 7, 1000000 times is : 0.22% \n",
    "The expected return of betting at number 7, 1000000 times is : -0.75% \n",
    "\n",
    "\n"
    ]
    }
    ],
    "source": [
    "simulation_list = [2,5,10,20,100,1000,10000,1000000]\n",
    "for n_simuls in simulation_list:\n",
    " roulette_simul(7,1,n_simuls)\n",
    " print(\"\\n\")"
    ]
    }
    ],
    "metadata": {
    "kernelspec": {
    "display_name": "Python 3",
    "language": "python",
    "name": "python3"
    },
    "language_info": {
    "codemirror_mode": {
    "name": "ipython",
    "version": 3
    },
    "file_extension": ".py",
    "mimetype": "text/x-python",
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
    "version": "3.7.3"
    }
    },
    "nbformat": 4,
    "nbformat_minor": 2
    }