statistics
CS 3130 / ECE 3530: Probability and Statistics for Engineers Due Tu 11/24
Homework 6: Estimation and Confidence Intervals Instructions: Submit two files on Canvas: the R code and written answers by 11:59pm on the due date. You can submit a pdf, Word doc, or txt file for the written answers. We highly recommend using LATEX or Word to format your answers. Everything should be electronic, do not submit a physical copy this time!
Make sure your R code is self-contained and runs without errors! Hint: you can test it like so:
rm(list = ls())
source("yourfile.r", echo = TRUE)
You may discuss the concepts with your classmates, but write up the answers entirely on your own. Be sure to show all the work involved in deriving your answers! If you just give a final answer without explanation, you may not receive credit for that question.
1. R Code: Exercise 23.3. Calculate the confidence interval in R.
2. R Code: Exercise 23.10. Do your calculations in R.
3. In this problem you are going to analyze the built-in R data set iris. First, extract the sepal width of the virginica species and save it to a vector x using this command:
x = iris$Sepal.Width[iris$Species == "virginica"]
Answer the following:
(a) R Code: Using a Gaussian approximation, what is the 95% confidence interval for the mean of x?
(b) R Code: Using a Student t distribution, what is the 95% confidence interval for the mean of x?
(c) R Code: Now assume that you only have the first 10 measurements. That is, create the vector y = x[1:10]. Repeat parts (a) and (b) for the vector y.
(d) How did the decrease in sample size affect the results? Were the two different confidence intervals affected differently?
4. Your friend flips a fair coin n times and tells you how many heads showed up. She does not tell you how many times she flipped the coin. She repeats this experiment 10 times (each experiment has n flips), and reports to you the number of heads for each experiment: x1, x2, . . . , x10.
(a) Give an unbiased statistic, n̂, that you would use to estimate n. Please include an argument for why the bias is zero.
(b) R Code: Simulate this experiment 1,000 times with n = 25 (each simulation will produce a list of 10 numbers). Use your statistic is part (a) to estimate n for each simulation (you should end up with 1,000 values for n̂).
(c) R Code: Plot a boxplot of your 1,000 n̂ values. Draw a horizontl red line where the true value of n is. Are your n̂ values centered roughly around the true value of n?
(d) R Code: Plot of histogram of your 1,000 n̂ values. What type of continuous distribution do you think would fit these well?
(e) R Code: Estimate the parameters of the distribution of your n̂ values (the distribution you answered in part (d)). Plot the pdf of this distribution on top of your histogram from part (d).
2