1. Simulate a fair coin.

1. Randmly sample $$N = 10$$ flips of a fair coin with replacement. Use the function sample().

2. Estimate the population mean using only the sample you just created.

3. Look at your friend’s answer to b. Did you two get the exact same number? Why or why not?

4. Repeat a. - c. with $$N = 100$$ and $$N = 1000$$. Did you and your friend get the same answers? Are these estimates more or less trustworthy than your solution to a. with $$N = 10$$?

5. Create a dataframe from your random sample with $$N = 1000$$. Your dataframe should have a column with flips of your “coin”, an index of flips, and a cumulative mean.

6. Use ggplot() to make a line plot with the roll number on the x-axis and the estimated mean on the y-axis.

2. Simulate an unfair coin.

1. Look up the help file for sample() by typing at the console ?sample. Read about the argument prob. There’s two constraints on the vector specified for the argument prob: the order of elements matches the order the vector sample() samples from, and the sum of prob must equal 1.

2. Repeat all the steps for 1.e. - 1.f. with you unfair coin.

3. Repeat parts 1.e - 1.f. with a fair die.

4. Repeat parts 1.e - 1.f. with an unfair die.

5. Challenge. Guess the population mean for all fair populations.

6. Challengier challenge. Guess the formula for the population mean for all fair populations. Can you generalize the formula to work for both a fair coin and a fair die?