Monte Carlo Simulation of the Craps Dice Game

Monte Carlo Simulation of the Craps Dice Game

Monte Carlo Simulation of the Craps Dice Game Sencer Ko Basics The player rolling the dice is the "shooter". Shooters first throw in a round of Craps is called the Come Out roll. If you roll a 7 or 11, you win and the round is over before it started. If you roll a 2, 3, or 12 that's a Craps and you lose: again, it's over before it started. Any other number becomes the Point. The purpose of the Come Out roll is to set the Point, which can be any of 4, 5, 6, 8, 9 or 10. Objective The basic objective in Craps is for the shooter to win by tossing the Point again before he tosses a 7. That 7 is called Out 7 to differentiate it from the 7 on the Come Out roll. If the Point is tossed, the shooter and his fellow bettors win and the round is over. If the shooter tosses Out 7, they lose and the round is over.

If the toss is neither the Point nor Out 7, the round continues and the dice keep rolling. Craps Game Come Out Roll Win if 7, 11 Set Point Lose if 2, 3, 12 Win if Point Continue otherwise Lose if 7 (Out 7) Win if Point Continue otherwise Lose if 7 (Out 7)

Questions What is the probability that the roller wins? Note that this is not a simple problem. The probability of win at later rolls depends on the point value, e.g., if the point is 8, P(8)=5/36 ({2,6}, {3,5},{4,4},{5,3},{6,2}) and if the point is 10, P(10)=1/36 ({5,5}). How many rolls (on the average) will the game last? Simulation and MATLAB We will simulate the craps game on a computer using MATLAB. The command rand(1) Uniformly distributed between 0 and 1 round(rand(1,2)*6+0.5)simulates a single roll of a pair of dice. The following MATLAB code simulates M games. MATLAB Code

M = 10; % Number of simulations lost = 0; win = 0; gamelength = zeros(1,M); disp(' win loss gamelength') data = zeros(10000,3); for k=1:M stop = 0; curr_gamelength = 1; x = sum(round(rand(1,2)*6+0.5)); if (x==7) | (x==11) win = win+1; stop = 1; elseif (x==2) | (x==3) | (x==12) lost = lost+1; stop = 1; else point = x; end MATLAB Code (Continued) while ~stop curr_gamelength = curr_gamelength+1; x = sum(round(rand(1,2)*6+0.5));

if (x==7) lost=lost+1; stop = 1; elseif (x==point) win = win+1; stop = 1; end end gamelength(k) = curr_gamelength; disp(sprintf('%8.0f %8.0f %8.0f '... ,win, lost, curr_gamelength)) data(k,:) = [win lost curr_gamelength]; end Sample Simulation Program Output Trial win 1 0 2 1 3 1 4 0

5 1 6 0 7 1 8 0 9 0 10 1 loss gamelength 1 2 0 7 0 3 1 2 0

5 1 10 0 8 1 2 1 4 0 1 Summary Data Total over 10 simulations win loss gamelength 5 5 4.4 Generation of Useful Data Remember we are using a random number generator! We also need a larger sample size. We will run the problem for many more games!

Let us now try 1000 games and divide #wins and #loss by M to determine the probabilities (comment out the disp commands to suppress output of data). Also evaluate the mean of gamelengths. Our point estimators are P(win) = data(1000,1)/1000 P(loss) = data(1000,2)/1000 L = mean(data(:,3)) Sample Simulations (M=1000) Trial 1 2 3 4 5 6 7 8 9 10 P(win)

0.479 0.496 0.497 0.467 0.512 0.485 0.480 0.494 0.492 0.495 P(loss) 0.521 0.504 0.503 0.533 0.488 0.515 0.520 0.506 0.508 0.505

L 3.646 3.774 3.351 3.450 3.386 3.435 3.476 3.591 3.466 3.312 Now make N=1000 such trials! This will take some time (about 5 minutes) since the MATLAB code is written for readability and not for speed! You may use the following command line: res=zeros(1000,3);for ii=1:1000; mcscraps; res(ii,:)=[win/1000 lost/1000 mean(gamelength)];end; Histograms 70

60 60 50 50 40 40 30 30 20 20 10

10 0 0.4 0.45 0.5 0.55 0.6 Histogram of P(win) for 1000 trials. 0 3 3.2 3.4 3.6

Histogram of L for 1000 trials. E P win p 0.4929 E L L 3.3748 var P win 2p 2.483 10-4 var L 2L 0.0083 3.8 Confidence Intervals P P 0.4929 t N 1,1 / 2 P win 0.4929 t N 1,1 / 2 1000 1000 t999,0.95 1.6464

0.4921 P win 0.4937 95% confidence interval L L t N 1,1 / 2 L 3.3748 t N 1,1 / 2 1000 1000 1.6464 3.3748 t999, 0.95 3.3701 L 3.3795 95% confidence interval Exact The exact value of probability of win can be calculated by using the theory of Markov Chains 0.4921 P win 0.4937 95% confidence interval 976 P win 0.4929 1980

Final Note The game length is an exponentially distributed random variable, however its mean over N=1000 trials (as shown before) is approximately normally distributed (Central Limit Theorem) 3500 3000 2500 2000 1500 1000 500 0 0

10 20 30 40

Recently Viewed Presentations

  • Determine holding period returns (i.e. total property returns

    Determine holding period returns (i.e. total property returns

    Apartment returns dominate the other property types when measuring . Unadjusted returns. Risk-adjusted return. Across geographic region. Across city tiers. Apartment and retail properties are an anecdotal hedge for inflation . Apartments and retail have the lowest ratio of Annual...
  • Semiotics of Literature

    Semiotics of Literature

    Indexicality in Literary Semiosis Harri Veivo University of Helsinki The Finnish Network University of Semiotics Peirce on indexicality For Peirce, indexicality is one of the three modes in sign functioning (in addition to iconicity and symbolicity) Designates and "existential" relation...
  • Understanding Narration - Houston Community College

    Understanding Narration - Houston Community College

    Understanding Narration. Narrative writers retell events to readers and relive the experiences themselves. Types. Description; Personal Essay. Is similar to a personal narrative in that it shares an event or experience but also reflects on the significant of the event...
  • Chapter 7

    Chapter 7

    Using energy considerations, calculate the average force the beam exerts on the pile driver while the pile driver is brought to rest. 31. A 40.0-kg box initially at rest is pushed 5.00 m along a rough, horizontal floor with a...
  • Ancient Greece

    Ancient Greece

    Gives protagonist advice (Usually) Supports the protagonist. The ideal spectator. Sets mood. Adds color and movement. Controls rhythm and tempo. ... Stage device in Greek and Roman drama in which a god appeared in the sky by means of a...
  • 2019 nfhs baseball rules powerpoint

    2019 nfhs baseball rules powerpoint

    2019 nfhs baseball rules powerpoint. B. Elliot Hopkins, MLD, CAA. ... For the set position, the pitcher shall have the ball in either his gloved hand or his pitching hand. His pitching hand shall be down at his side or...
  • The Animal Kingdom Chordates

    The Animal Kingdom Chordates

    Most chordates have a post-anal tail. In contrast, nonchordates have a digestive tract that extends nearly the whole length of the body. Phylum Chordata. Chordata includes 3 subphyla: ... Examples: fish, amphibians, reptiles, birds, mammals.
  • Chapter 16 Cholinesterase Inhibitors

    Chapter 16 Cholinesterase Inhibitors

    Chapter 62 Birth Control * * Birth Control Interfering with the reproductive process at any step from gametogenesis to nidation (implantation of a fertilized ovum) Selecting a Birth Control Method Consider: Effectiveness Safety Personal preference Fig. 61-1.