Instructions

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.

Deadlines

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).

Goal

The purpose of this challenge is to set you up to be able to simulate more complicated games of chance.

Questions

  1. 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).

  2. Simulate many rounds of this game (e.g. 10,000 bets of $1 on 5).

  3. 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.)

  1. Find the distribution of gambler wealth at time \(t\) (e.g. after 100 rounds).
  2. Find the distribution of gambler “life span” (i.e. how long till gamblers run out of money).

Extra credit #1

  1. Discuss, implement, and evalutate possible betting strategies (e.g. might it be wise to bet on something other than whatever number was rolled last round? How could you make R do that for you?)

Extra credit #2

  1. Poker stuff…
  1. Make an R function that deals poker hands from a standard deck.
  2. Make a function that compares two poker hands and tells you if the first hand is better or worse than the second hand.