Exercise

# Exercise 3 - Sampling From the Normal Distribution

In a previous section, we repeatedly took random samples of 50 heights from a distribution of heights. We noticed that about 95% of the samples had confidence intervals spanning the true population mean.

Re-do this Monte Carlo simulation, but now instead of \(N=50\), use \(N=15\). Notice what happens to the proportion of hits.

Instructions

**100 XP**

- Use the
`replicate`

function to carry out the simulation. Specify the number of times you want the code to run and, within brackets, the three lines of code that should run. - First use the
`sample`

function to randomly sample`N`

values from`x`

. - Second, create a vector called
`interval`

that calculates the 95% confidence interval for the sample. You will use the`qnorm`

function. - Third, use the
`between`

function to determine if the population mean`mu`

is contained between the confidence intervals. - Save the results of the Monte Carlo function to a vector called
`res`

. - Use the
`mean`

function to determine the proportion of hits in`res`

.