200 likes | 309 Views
Background Information. Joe Gamble loves to play craps at the casinos.He suspects that his chances of winning are less than 50-50, but he figures that he can at least play for quite a while before losing all of his cash.Assuming that he starts with $50 and each bet is worth $5, he wants to know wh
E N D
1. Example 12.15 Simulating Games of Chance
2. Background Information Joe Gamble loves to play craps at the casinos.
He suspects that his chances of winning are less than 50-50, but he figures that he can at least play for quite a while before losing all of his cash.
Assuming that he starts with $50 and each bet is worth $5, he wants to know whether he can play 100 games without going broke.
3. Solution We will solve this problem in two parts.
First, we will simulate a single game. By running this simulation for many iterations, we will find the probability that Joe wins a single game.
Then we will run a second simulation, using the probability from the first simulation, to determine whether Joe can play games without going broke.
4. CRAPS1.XLS The first simulation model is for a single game, which we will iterate repeatedly.
The model can be seen on the next slide and in this file.
6. Developing the Model There is a subtle problem here we do not know how many tosses of the dice are necessary to determine the outcome of a single game.
Theoretically, the game could continue forever, with the player waiting for his point or a 7.
However, it is extremely unlikely that more than, say, 40 tosses will be necessary in a single game.
Therefore we will simulate 40 tosses and use only those that are necessary to determine the outcome of a single game.
7. Developing the Model The steps required to simulate a single game are as follows.
Simulate tosses. Simulate the results of 40 tosses in the range B5:D44 by entering the formula =RISKDUNIFORM({1, 2, 3, 4, 5, 6}) in cells B5 and C5 and the formula =SUM(B5:C5) in cell D59. Then copy these to the range B6:D44. The @Risk function RISKDUNIFORM takes a list of numbers and randomly selects one of the numbers from the list, where each number has equal probability. DUNIFORM stands for discrete uniform.
8. Developing the Model -- continued First toss outcome. Determine the outcome of the first toss with the formulas =IF(OR(D5=7,D5=11),1,0), =IF(OR(D5=2,D5=3,D5=12),1,0) and =IF(AND(E5=0,F5=0),Yes,No) in cells G5 and H5, and I5. Similarly, the OR condition in cell H5 checks whether he loses right away. In cell I5, we use the AND condition to check whether both cells G5 and H5 are 0, in which cast the game continues. Otherwise, the game is over.
Outcomes of other tosses. Assuming the game continues beyond the first toss, Joes point is the value in cell D5. Then we are waiting for a toss to have the value in D5 or 7, whichever occurs first. To implement this logic, enter the formulas =IF(OR(G5=No,G5=), ,IF(D6=$D$5,1,0)), =IF(OR(G5=No,G5=), ,IF(D6=7,1,0)) and =IF(OR(G5=No,G5=), ,IF(AND(E6=0,F6=0),Yes,No)) in cells G6, H6, and I6.
9. Developing the Model -- continued Then copy these to the range G7:I44. The OR condition in each formula checks whether the game just ended on the previous toss or has been over for some time, in which case blanks are entered. Otherwise, the first two formulas check whether Joe wins or loses on this toss. If both of these return 0, the third formula returns Yes. Otherwise, it returns No.
Game outcomes. We keep track of two aspects of the game in @Risk output cells, whether Joe wins or loses and how many tosses are required. To find these, enter the formula =RISKOUTPUT( )+SUM(E5:E34) and =RISKOUTPUT( )+COUNT(E5:E34) in cells B47 and B48. Note that both functions, SUM and COUNT, ignore blank cells.
10. @Risk Results We set the number of iterations to 10,000 and the number of simulations to 1.
After running @Risk, we obtain the summary results shown on the next slide.
Perhaps the most important result is the mean value in the first row of the summary table.
This is the average of the sequence of 1s and 0s in cell B47.
Hence, it is the fraction of times Joe won. This value is quite accurate.
12. @Risk Results -- continued It can be shown with the probability argument that the probability of winning in craps is 0.493.
From the outputs on the number of plays, we see that one game lasted 29 tosses, but that most games are over after a few tosses.
The purpose of the second simulation is to see whether Joe can play 100 games before going broke.
In case he does go broke, we keep track of the number of games he was able to play.
13. CRAPS2.XLS The second simulation model appears on the next slide and shows an example where Joe went broke on the 24th play. The rows for plays 26-100 are not shown in the figure.
The model can also be seen in this file.
15. Developing the Second Model The following steps are required.
Inputs. Enter the inputs in the shaded range.
First simulated game. The results of this simulated games appear in the range B11:B110. Although Joe might go broke before playing all 100 games, we simulate all 100 just in case. For the first simulated game enter the formulas =InitWealth, =IF(RAND( )<PrWin,1,0), =IF(C11=1,B11+BetSize,B11-BetSize) and =IF9D11=0,Yes,No) in cells B11-E11.
16. Developing the Second Model -- continued Other simulated games. The logic for other games is the same as for the first game except that we check whether Joe is already broke. To do this, enter the formulas =IF(OR(E11=Yes,E11=), ,D11)=IF(OR(E11=Yes,E11=), , IF RAND( )<PrWin,1,0))=IF(OR(E11=Yes,E11=), ,IF(C12=1,B12+BetSize,B12-BetSize)) and=IF(OR(E11=yes,E11=), ,IF(D12=0,yes,No)) in cells B12-E12 and copy these down to row 110. As in the previous model, blanks will be entered after Joe goes broke if this ever happens.
17. Developing the Second Model -- continued Output cells. Joe goes broke only if the label in D110 is Yes or blank. Also, the number of games he plays is the number of nonblank values in column C. Therefore, enter the formulas =RISKOUTPUT( )+IF(OR(E110=Yes,E110=),1,0) and =RISKOUTPUT( ) + COUNT(C11:C110) in cells H11 and H12 to calculate these outputs.
18. @Risk Results We set the number of iterations to 1000 and the number of simulations to 1.
After running @Risk, we obtain the outputs on the next slide.
As in the previous model, the mean in the first row of the summary table indicates the fraction of time Joe goes broke about 41% of the time.
The histogram indicates that he gets to play 100 games most of the time, but that there are a few times when he goes broke early.
20. @Risk Results -- continued In fact, there was at least one iteration out of 1000 where he went broke after only 10 plays.
This could occur in only one way: he lost 10 games in a row!
On the more optimistic side, the 5th percentile shows that Joe will be able to play more than 24 games about 95% of the time.