Exercise

Exercise 4 - Sampling from the t-Distribution

\(N=15\) is not that big. We know that heights are normally distributed, so the t-distribution should apply. Repeat the previous Monte Carlo simulation using the t-distribution instead of using the normal distribution to construct the confidence intervals.

What are the proportion of 95% confidence intervals that span the actual mean height now?

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. Remember to use the qt function this time to generate the confidence interval.
  • 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.