Skip to content

A simulation of "Gamblers Ruin" a classic statistics problem that simulates the gain from gambling with constant probability of gain or losing money

Notifications You must be signed in to change notification settings

leta199/Random-Walks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

Random Walks

A simulation of "Gamblers Ruin"- this is a classic statistics and modelling problem to peer into the expected amount of money won or lost based on probabilities of winning or losing a specific amount of money through betting. This simulation utilises a constant probablity of success to simulate a random walk with a lose or gain of $1/ bet.

We will look into a casino that has 100,000 bets a month and identify the expected gains we expect from these bets in a month. Each bet represents a loss or gain of $1, therefore we will investigate aspects of this month for the casino such as probabilites of outcomes and amount the casino makes.

This project will cover:

  • Setting up simulation parameters (number of bets, number of repetitions).
  • Simulating an amount won after 100,000 bets.
  • Simulating "Gamblers Ruin" using random walks.
  • Graphing the random walk and finding the probability of making between $4600 and $6000 from 100,000 bets in a casino.

HOW IT'S MADE

Languages used: R (version 4.5.1)
Environement: RStudio

Language: R Built with RStudio Status

METHODS AND TECHNIQUES

Practice simulation
Setting up the number of bets per month (100,000) as n. Setting up the probability of success and failure for each bet at 20/38 and 18/38. Defined totalgain as a test run of the amount for 1 simulation run.

Simulation loop

  • Set seed for reproducibility.
  • Defining the total number of bets made per month (100,000).
  • Creating a random walk by sampling between gains of $-1 and $1 with the given probabilities and number of bets per month.
  • Plotting the randomwalk via "distance" from our start point of $0.
Image

FUNCTION EXPLANATION

In an effort to identify how the casino will perfrom we will simulate the probability of the casino generating a specfic interval of money for each month. In this case, we want to know what the probability of the casino earning between $4600 and $6000.

sim4ot6 - a function that simulates the probability of the casino generating between $4600 and $6000.

This function: Has a list list4to6 - stores an list of 100,000 values generated from the proabilities given above to earn -$1 and $1.
If the sum for each list generated is between $4600 and $6000 store the number 1 and 0 if not.

We then replicate this simulation 5000 times and get the mean of the outcome stored in mean4to6 using mean() and replicate(). Thus we can see that the probability of the casino making between $4600 and $600 dollars is 99.04%

PROJECT STRUCTURE

|Simulation- Random Walks
|├── Randomwalk R script
|└──Random latex

AUTHORS

leta199

About

A simulation of "Gamblers Ruin" a classic statistics problem that simulates the gain from gambling with constant probability of gain or losing money

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages