https://classroom.github.com/a/4X9qFO7N

**Due: 2020-04-06 by 11:59pm**

Assume the population distribution of interest is \(\text{Exponential}(\lambda = 3)\).

Generate a random sample of \(N = 314\) observations from the population of interest and store it into a vector named

`x`

.In a for loop of length

`R = 1001`

, repeatedly sample with uniform probabilities and with replacement observations from the vector`x`

. For each re-sampled vector, calculate and store the sample mean. Don’t forget to pre-allocate your memory.Make a density plot of the

`R`

sample means.Describe the sampling distribution of the sample mean. What approximate shape does it take on? Why? Explain.

Will the width of the sampling distribution get wider or narrower as your sample size increase? If you’re not sure, change

`N`

above and repeat`a.`

through`c`

to find out.Use the function

`quantile()`

, along with the vector of bootstrap re-sampled means, to calculate an 80% confidence interval for population mean. Interpret this confidence interval.

Assume the population distribution of interest in \(\text{Binomial}(K = 15, p = 0.4)\).

Use the function

`rbinom(N, K, p)`

to generate a random sample of \(N = 314\) observations from the population of interest and store it into a vector named`x`

.Write in R a function that returns negative one times the simplified log-likelihood for

`N`

observations from the population of interest. The function signature should be

`ll_binomial <- function(p, K, X) {...}`

- Use the function
`optim(...)`

, along with the vector named`x`

that you generated in`a.`

, to find the maximum likelihood estimate of \(p\), \(\hat{p}\) by minimizing the function your wrote in part`b.`

. Remember that \(p\) is bounded between \(0\) and \(1\), such that you should set the`lower`

and`upper`

bounds as arguments to`optim()`

.