MATHS2003 Profit, Loss and Gambling: Lab Week 3 - Excel and Probability
MATHS2003 Profit, Loss and Gambling: Lab Week 3 - Excel and Probability
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.
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.
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
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.
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
Was the theoretical probability the same as the simulated probability? Why/why not?
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
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?
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?
………………………………………………………………………………………………
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.
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………