Simulate a fair coin.

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

`sample()`

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

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

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\)?

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.

Use

`ggplot()`

to make a line plot with the roll number on the x-axis and the estimated mean on the y-axis.

Simulate an unfair coin.

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.Repeat all the steps for 1.e. - 1.f. with you unfair coin.

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

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

Challenge. Guess the population mean for all fair populations.

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?