Create an R script (named by the formula your_name_chance.R
) that answers the questions below.
I expect you to ask questions on the class blog or the class discord over the course of the week while you complete this challenge. Such participation will affect your grade.
There is a hard and a soft deadline for this challenge. To get a check-plus, you must turn it in by the soft deadline of before next Monday’s class (Oct 19th). To get a check, you must turn it in by the hard deadline: the following class (Oct 21st). Extra credit submissions will be considered in either case and may allow a late submission to earn a check-plus or higher. Submissions after the hard deadline will only be accepted if they are complete and will only score a check-minus (3 out of 5 points).
The purpose of this challenge is to set you up to be able to simulate more complicated games of chance.
Simulate one round of a game where you choose a number between 1 and 6, bet some amount of money, roll a “die” (hint: help(runif)
and either round
, floor
, or ceiling
), and get 5 times your bet if that roll comes up (and 0 otherwise).
Simulate many rounds of this game (e.g. 10,000 bets of $1 on 5).
Simulate a gambler playing this game with finite wealth (e.g. starting the game with $100 and stopping if they ever get down to $0.)