Turn in one copy for each group. Please turn in **both an HTML file and your R Markdown script**. This is due Thursday, February 2 at noon. Groups *may* be asked to talk about their results in class on Thursday. Select assignments may also be posted on the course website. Please identify the primary coder, as this will need to rotate through the semester, and other’s may be asked to describe the findings in class.

## Lab Overview

For this lab we will focus on writing code for simulations. Next week in class we will discuss loops and Monte Carlo procedures.

The entire lab will be worth 100 points. Clarity of code, including comments and interpretable variables names, along with thoughtful writing with an emphasis on concise interpretations will be worth 10.

## Questions

Answer the following questions in this R Markdown document. Please include code where necessary.

### 1. Roulette Simulation

In class we discussed and wrote a function to simulate a roulette spin. We use a spinner with 38 spots including 0 and 00 as green and for simplicity assume all even integers between 1 and 36 are red, while the evens are black.

#### b (20 points)

Using this function, compute the probability of rolling a red value. How does this compare to the analytical solution for the probability?

#### d (30 points)

Write a function that takes two arguments, a color (red or black) and a bet amount and returns the earnings. In roulette if you place a $1 on a color, you win $1 if your color is selected. Note: this function will likely call the previous function we specified for Roulette spins.

#### e (20 points)

Simulate a series of 100 $1 bets on red. Assuming you started with $100, how much money do you have at the end of the $100 bets?

### 2. Black-Jack

#### a. (30 points)

Implement a procedure (this does not need to be a function) to estimate the probability of being dealt black-jack (2 cards that total 21). If you are unfamiliar with black jack, wikipedia provides a nice overview.