You are on page 1of 4

MATHS2003 Profit, Loss and Gambling

Lab Week 3 – Excel and Probability

SIMULATING TWO DICE

Section 1 – Random Numbers and Excel


Throughout this course, we will use random numbers a lot to simulate what can occur in various
gambling games. Let’s examine how Excel generates random numbers.

In cell A1, type =RAND(). Alternatively, you could use Excel’s function wizard and select Insert >
Function > Math & Trig > RAND. Either of these procedures generates a random number between 0
and 1. Write down the random number that was generated in cell A1.

………………………………………………………………………………………………

Generate another random number in cell A2. What happened to the random number in cell A1?

………………………………………………………………………………………………

Although it is useful in a spreadsheet to automatically recalculate cells, it is often a problem with random
numbers. This can be overcome by using Excel’s cut and paste facilities. Copy cells A1:A2. Select Edit
> Copy. Leaving the same cells highlighted, select Edit > Paste Special > Values. Click in cell A1 and
then hit enter. The random numbers are now regarded simply as numeric rather than having a formula
attached.

We don’t always want a random number in the interval 0 to 1. In order to simulate a roll of a die, for
example, we need to generate a random integer (whole number) from 1 to 6. Click on cell B1 and type
=A1*6+1. The random number in cell B1 should be a number between 1 and 6.9999. To represent the
outcomes of a roll of a die, this random number should be an integer. Click on cell C1 and type
=INT(B1). You should now have a random number between 1 and 6 inclusive.

Section 2 – Simulating the Sum of Two Dice


Now that we have demonstrated how to simulate the roll of a die, clear all of the numbers from your
worksheet. One way to model the total obtained when two dice are rolled would be to actually roll the
dice a large number (say 1000) times and count the number of times that the individual totals appear. It
is quicker and easier to do a computer simulation.

Click on cell A1 and type Rolling Two Dice

Click on cell A3 and type =INT(RAND()*6+1). Click on cell B3 and type =INT(RAND()*6+1). Write down
in your own words what these formulas are doing.

………………………………………………………………………………………………

………………………………………………………………………………………………

CRICOS Provider No. 00103D Insert file name here Page 1 of 4


Highlight cells A3 and B3 and drag down to cells A1002:B1002. To change the random numbers to their
values, select Edit > Copy, Edit > Paste Special > Values. The first column represents 1000 rolls of
the first die and the second column represents 1000 rolls for the second die. Use an appropriate
function to obtain the total for the two die in column C. Column C should now represent the totals for
1000 rolls of both dice.

Section 3 – Probability Distribution


We will now set up a table to display the probability model. If the experiment is to roll two dice and
examine their total, write down the sample space.

………………………………………………………………………………………………

………………………………………………………………………………………………

In cell E3, type Total and below it in cells E4 to E14 type in the numbers 2, 3, 4, … , 12.

To count the number of times that the total 2 appears, the COUNTIF function is used. Click on cell F4.
Select Insert > Function > All > COUNTIF. For the range, type $C$3:$C$1002 and for the criteria type
E4. Drag the contents of cell F4 down to cell F14. To express these results as probabilities divide by
1000. Do this in column G with the heading Probability.

You now have a probability model for the total of two dice. Save your worksheet.

Which total had the highest probability of occurring?

………………………………………………………………………………………………

Did others around you obtain a similar result?

………………………………………………………………………………………………

What is the sum of the numbers in column G?

………………………………………………………………………………………………

Is this a proper probability distribution? Why/why not?

………………………………………………………………………………………………

What is the theoretical probability of rolling a 12?

………………………………………………………………………………………………

Was the theoretical probability the same as the simulated probability? Why/why not?

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

COIN TOSSING GAME

CRICOS Provider No. 00103D Insert file name here Page 2 of 4


Suppose Wilma and Betty toss a fair coin a large number of times. Each time the coin shows heads
Wilma gets $1 and each time it’s tails Betty gets the same reward. Over the course of the game what do
you predict will happen in terms of who will be in front and how often?

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

On the graph below, draw a quick sketch of what you think will happen for Wilma in terms of her
winnings over the course of the game.

Wima’s
Winnings

Number of
games

Let’s get Excel to simulate and graph what might happen (a neater option than flipping a coin for a few
hours). How would you simulate the result of one flip of a coin using Excel? Hint: think numbers not
letters.

………………………………………………………………………………………………

………………………………………………………………………………………………

Start a new worksheet. In cell A1, type Result. We will generate 4000 flips of a coin in cells A2:A4001.
A 1 will represent heads and a 2 will be tails. Write down a formula that will simulate the result from one
flip of a coin.

………………………………………………………………………………………………

Type this formula into cell A2 and then drag it down to cell A4001. You should have 4000 ones or twos
to represent heads and tails. We don’t want these numbers to change, so make sure you change these
random numbers to values only.

In column B, we will track the wins and losses of Wilma. Note that we need to do this for one person
only, as the other person will simply have the opposite money. So if a head (1) results, Wilma will gain
$1 and conversely lose $1 if it is tails. We will use the IF function to check if we should add or take away
$1.

Go to cell B2 and select Insert > Function > IF. In the logical_test box, type A2 = 1. This simply tests
whether the contents in cell A2 is ‘1’ or not. If this statement is true (we did roll a head), then we want to
add $1. Type 1 into Value_if_true box. What number are you going to type in the Value_if_false box?

CRICOS Provider No. 00103D Insert file name here Page 3 of 4


………………………………………………………………………………………………

Copy this formula in cell B2 down to cell B4001. You should have a series of positive and negative ones
in column B. We don’t just want to know the result after each toss. We want to add up the total winnings
for Wilma as the game goes on. We will do this in column C. Type Total Winnings in C1. In C2, type
=B2. Why have we done this?

………………………………………………………………………………………………

What are you going to type in cell C3 to total the result from two flips of the coin?

………………………………………………………………………………………………

Drag C3 down to C4001.

We need a graphical representation of Wilma’s winnings (or losses) over the 4000 flips. Highlight cells
C2:C4001. Select Insert > Chart. From the Chart type box, select Line. Select the top left chart sub-
type. Click Next > Next.

On Step 3 of 4 enter in an appropriate heading and label your graph’s axes. Click Next > Finish. Did
others around you obtain similar graphs?

………………………………………………………………………………………………

What does it mean when your line graph goes below $0?

………………………………………………………………………………………………

………………………………………………………………………………………………

Generally, discuss what the graph tells you about the game between Wilma and Betty.

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

Were you surprised by the results? Why/why not?

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

CRICOS Provider No. 00103D Insert file name here Page 4 of 4

You might also like