Notes:
1) The MATLAB command randi(k) generates a random
integer in [1,...,k] that’s uniformly
distributed, i.e. every value in the integer range [1,...,k] is equally
likely.
Calling the randi function several times in a row (for example via a
for-loop) yields mutually independent results (for practical
purposes anyway; strictly speaking, they are actually
pseudo-random number generators, and cannot yield true
unpredictability). For more information, type ‘help randi’ in the
MATLAB command window.
2) In a large number n of independent trials of an experiment, the
empirical number of times k that an event B occurs in a trial
satisfies
k ≈P[B]. n
This is an imprecise statement of the law of large numbers – you
will get a first taste of this phenomenon in this workshop but the
precise theory will come later in the subject.
3) Use the MATLAB help function to get support regarding
working with MATLAB (googling what you are looking for helps
too).
4) The main purpose of this workshop is to get you to recognize
“sequential experiments” and practice analysing and structuring
the information that is given to you in order to compute
probabilities, particularly getting your head around the notion of
“sample space”. Also you’ll get a first taste of the law of large
numbers.
Simulation of Games with Dice and Goats (total = 36 marks + 4
on-time attendance marks)
Part I. Let’s introduce the following game of chance: it is played
by rolling a pair of dice and observing the total number of spots on
their top faces. Assume that each of the dice has three sides with
only 1 spot and 3 sides with only 2 spots (all sides are assumed to
occur equally likely). As a result, for each roll the total number of
spots on their top faces is an integer between 2 and 4. The rules of
the game are as follows:
• If T(1) equals 2 then the player loses immediately.
• If T(1) is any other number x, then the player keeps rolling the
two dice, yielding totals T(1),
T(2), T(3), T(4), T(5), ... each
time until either
i) he rolls a total of x again, in which case
he wins, or ii) he rolls a total of 2, in which case he loses.
Part I Questions
I-a)(1 mark) Draw a tree diagram for this
game, making sure that you label the branches with their
corresponding probabilities.
I-b)(2 marks) Specify the
sample space S for this game.
I-c)(1 mark) Observe the total
number of rolls in the game. What are the possible outcomes?
I-d) (2 marks) Show that the probabilities of the outcomes
of your answer to the previous question add up to 1, by using
the geometric series formula.
I-e)(1 mark) What is the
probability that the game never finishes? Explain your
answer.
I-f) (2 marks) Calculate the probability that the
player wins, using the geometric series to get an exact value.
I-g)(5 marks) Write MATLAB code to simulate the game.
Make sure that you generate an output that indicates whether
the player lost or won.
I-h)(2 marks) Write a program that
calls your MATLAB procedure from the previous question
n=10 times and gives the fraction of times that the player
wins. Include the output of your MATLAB simulation in
your report.
Questions continue on the next page
. I-i) (1 mark) Repeat the previous question with n = 50,000.
. I-j) (2 marks) Comment on how well or poorly your results in
(I-h) and (I-i) relate to your answer in
(I-f). Show the
evidence.
I-k) (4 marks) Repeat (I-g) , (I-h) and (I-i) for the case that each
dice is a normal dice, with 1,2,3,4,5 and 6 spots on its sides (so
then, for each roll, the total number of spots is an integer between
2 and 12). From your simulation give an estimate of the probability
that the player wins.
Part II.
The Monty Hall Game Show problem. Consider a game show in
which there are three closed doors, with a car behind one and goats
behind the others. According to the rules of the game, the player
first selects a door and the game show host (called Monty Hall)
then opens one of the other doors, to reveal a goat. The player is
then given a choice: either she retains the original selection, or she
switches to another door.
Part II Questions
II-a) (3 marks) Write MATLAB code to simulate the game. More
specifically, you need to write two MATLAB procedures:
a. Procedure 1 assumes that the player sticks to her original
selection;
b. Procedure 2 assumes that the player switches.
Make sure that
you generate an output that indicates whether the player lost or
won.
II-b) (2 marks) For each of your MATLAB procedures from (II-a),
write a program that calls the procedure n=10 times, and gives the
fraction of times that the player wins. Include the outputs of your
MATLAB simulation in your report.
II-c) (1 mark) Repeat (II-b) with n=50,000.
II-d) (3 marks)
Calculate the probability of winning the car if the player switches
to a door
that is different from her original selection. Explain your
answer.
II-e) (2 marks) Comment on how well or poorly your
results in (II-b) and (II-c) relate to
your answer in (II-d). Show the evidence.
II-f) (2 marks) What
should the contestant do if she wants the car? Switch or not
switch?
Explain your answer.