0% found this document useful (0 votes)
54 views

STC122 - Assignment 2 - Submission Instructions - 2022

Uploaded by

Layola Mdlalo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

STC122 - Assignment 2 - Submission Instructions - 2022

Uploaded by

Layola Mdlalo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

stc122

stc122 - Assignment 2 submission


Instructions:
o Answer the questions that follow and save all your code in a single R script, named Assignment2.R
where Assignment2 is the filename and .R is the file extension.
o Two submissions are required for this Assignment, namely a code submission and an interpretation
submission. The icons below,  and , are used in the questions to indicate the submission where
you are required to submit the answer.

Submission 1: Code 
o Submit your R script on Gradescope before Tuesday, 13 September 2022, 23:59.
o Multiple code submissions are allowed and your autograded results will be available shortly after
each submission.
o Ensure all variables are named correctly, as incorrectly named variables will not be awarded any
marks. (Remember variable names are case sensitive.)
o Ensure your code does not contain any syntax errors. If your code produces errors when run, the
autograder will not be able to mark it
o Any code commented out will be considered rough work and will not be marked.
o You will be expected to upload the plots produced in R during Submission 2. Ensure that these plots
are clear and labelled appropriately. Save the plots you created as .jpg or .png files on your device
while doing Submission 1, so that these plots are available for you during Submission 2.
o Once you have completed your submission, ensure the file is submitted on Gradescope with the
correct file name, Assignment2.R where Assignment2 is the filename and .R is the file extension.
The autograder will only be able to grade your submission if you use the correct filename.

Submission 2: Interpretation 
o After completing the code submission, also complete the interpretation submission. This online
assignment needs to be completed before Tuesday, 13 September 2022, 23:59. Note that
Gradescope will not allow you to submit after this time (unlike ClickUP).
o You will only have one attempt which must be completed in one sitting. Even if you close the
browser, the timer will continue counting down.
o You will have 60 minutes to complete this submission.
o If you accidentally submit your submission but you still have time left, simply click on the resubmit
button to continue. The resubmit button will disappear when the timer runs out. You will be
expected to upload plots produced in R. Ensure that these plots are clear and labelled appropriately.
Save the plots you created on your device before opening the interpretation submission.

Guidelines:
o This assignment is based on Lab 2, Probability, available on ClickUP. You should first work through
Lab 2 before attempting to do this assignment.
o To complete this assignment, students need to be familiar with the board game Snakes and Ladders.
For those unfamiliar with the game, please watch the following short video before attempting the
assignment: https://www.youtube.com/watch?v=a-kTZF2EEKc

Copyright reserved: University of Pretoria, Department of Statistics 1


stc122

o The die considered for this assignment is a fair 6-sided die. A die is considered fair if there is an
equal probability of the die landing on any one of its sides. For example, a six-sided die is
considered fair if there is precisely a 1/6 probability of landing on any side. For more details, see
the relevant examples on dice in the Probability supplemental chapter available from the OpenIntro
website: https://www.openintro.org/go?id=stat_os4_probability_chapter&referrer=/book/ims/index.php
o Usually the board layout for Snakes and Ladders is from 1 to 100. Consider for this assignment the
following board layout for Snakes and Ladders from 1 to 36:

o With respect to the rules of the game for this assignment, take note of the following adjustments
(see above-mentioned video for reference):
º To begin the game on the board, the first roll of the die does not have to be a 1. In effect, if
your first roll is a 3, for example, then you can immediately place your token on 3 (and climb
the ladder to 16).
º Ignore “rules of the sixes” (rolling a 6 gives you another turn).
º To complete the game, you have to end on 36 or more. That is, the final roll of the die does
not have to result in your token ending exactly on 36. For example, if your token is on 34,
then you complete the game if your next roll of the die gives 2, 3, 4, 5 or 6.
º Ignore “the bounce back twist”.
o Where applicable, answer the questions below by typing the appropriate code in the R script
template provided on ClickUP. Some questions are theoretical and no coding is needed to answer
those questions.
o You need the openintro package for this assignment. Ensure that you install the package prior
to starting the assignment.
o When using code from a website, reference it by adding the URL as a comment in your code.

1
https://www.pinterest.com/pin/195132596330472843/

Copyright reserved: University of Pretoria, Department of Statistics 2


stc122

Questions:

o Let the random variable 𝑋 be the value observed for a roll of the die.
o Let the random variable 𝑌 be the number of rolls of the die required to complete the game.

1.  What is the probability distribution of 𝑋?

2.  What is 𝐸(𝑋), the expected value of 𝑋?

3. Consider the first turn in the game. Let event 𝐴 be that a ladder is climbed on the first turn and let
event 𝐵 be that the token lands on an even-numbered block on the first turn.

a)  Determine the probability of event 𝐴.


b)  Given that a ladder is climbed in the first turn, determine the probability that the token
lands on an even-numbered block.
c)  Given that a ladder is not climbed in the first turn, determine the probability that the
token lands on an even-numbered block.
d)  Draw a tree diagram of the possible outcomes and probabilities. Let event 𝐴 be the first
level and event 𝐵 be the second level in the tree diagram. Where applicable, give probabilities
to three decimal places (for instance, let digits = 3).
e)  Using the tree diagram, calculate the probability of event 𝐵.
f)  Using the tree diagram, calculate the probability that a ladder is climbed in the first turn
given that the token landed on an even-numbered block.

Attempt the following questions assuming there are no snakes or ladders present on the
board.

4.  Does 𝑌 have a well-known probability distribution?

5.  What is the maximum value of 𝑌?

6.  What is the minimum value of 𝑌?

7.  Calculate 𝐸(𝑌), the expected value of 𝑌. Save your response into a variable called Q7

8.  Simulate a single game of Snakes and Ladders. Use a seed value of 12. How many rolls of the die
were needed to complete the game? Save your response into a variable called Q8

9.  Repeat the above simulation for Snakes and Ladders 100 different times. Use a seed value of 17.
After each iteration, save the number of rolls of the die required to complete the game. Save your
vector of 100 responses into a variable called Q9

a)  What is the mean number of rolls of the die needed to complete the game? Save your response
into a variable called Q9a
b)  Compare the answer in Question 9a to 𝐸(𝑌) in Question 7.

Copyright reserved: University of Pretoria, Department of Statistics 3


stc122

c)  What is the median number of rolls of the die needed to complete the game? Save your
response into a variable called Q9c
d)  What is the standard deviation of the number of rolls of the die needed to complete the game?
Save your response into a variable called Q9d
e)  Using the plot function, draw a barplot of the 100 simulated number of rolls of the die
needed to complete the game.

Attempt the following questions assuming the snakes and ladders have been added to
the board as shown in the given board layout.
10.  Simulate a single game of Snakes and Ladders. Use a seed value of 20. How many rolls of the die
were needed to complete the game? Save your response into a variable called Q10

11.  Repeat the above simulation for Snakes and Ladders 100 different times. Use a seed value of 25.
After each iteration, save the number of rolls of the die required to complete the game. Save your
vector of 100 responses into a variable called Q11

a)  What is the mean number of rolls of the die needed to complete the game? Save your
response into a variable called Q11a
b)  Compare the answer in Question 11a to 𝐸(𝑌) in Question 7 as well as to the answer in
Question 9a.
c)  What is the median number of rolls of the die needed to complete the game? Save your
response into a variable called Q11c
d)  Compare the answer in Question 11c to the answer in Question 9c.
e)  What is the standard deviation of the number of rolls of the die needed to complete the
game? Save your response into a variable called Q11e
f)  Compare the answer in Question 11e to the answer in Question 9d.
g)  Using the plot function, draw a barplot of the 100 simulated number of rolls of the die
needed to complete the game.

12.  Consider the final snake on the board from 35 to 22. Assume this snake is replaced with a snake
from 35 to 6. Redo the simulation in Question 11. Use a seed value of 33. After each iteration, save
the number of rolls of the die required to complete the game. Save your vector of 100 responses
into a variable called Q12

a)  What is the standard deviation of the number of rolls of the die needed to complete the
game? Save your response into a variable called Q12a
b)  Compare the answer in Question 12a to the answers in Questions 9d and 11e.

Copyright reserved: University of Pretoria, Department of Statistics 4

You might also like