1. Consider the population \(\{3, 6, 7, 9, 11, 14\}\). For samples of size 3 without replacement, find (and plot) the sampling distribution of the minimum. What is the mean of the sampling distribution? The statistic is an estimate of some parameter—what is the value of the parameter?
pop <- c(3,6,7,9,11,14)
min(pop)
[1] 3
minimum <- apply(combn(pop, 3), 2, min)
minimum
 [1] 3 3 3 3 3 3 3 3 3 3 6 6 6 6 6 6 7 7 7 9
mean(minimum) #mean of sampling dist
[1] 4.8
ggplot(data=data.frame(minimum), aes(x = data.frame(minimum))) +
  geom_density() +
  theme_bw()

The mean of the sampling distribution is mean(minimum) = 4.8
The value of the parameter is min(pop) = 3

  1. Let \(X_1, X_2, \ldots, X_n\) be a random sample from some distribution and suppose \(Y = T(X_1, X_2, \ldots, X_n)\) is a statistic. Suppose the sampling distribution of \(Y\) has pdf \(f(y) = (3/8)y^2\) for \(0 \leq y \leq 2.\) Find \(P(0 \leq Y \leq 1/5)\).
funct <- function(x){3*x^2/8}
integrate(funct, 0, 2)$value #should be a 1
[1] 1
integrate(funct, 0, 1/5)$value
[1] 0.001
curve(funct)
abline(v=0)
abline(v=1/5)
abline(h=0)

integrate(funct, 0, 1/5)$value
[1] 0.001

\(P(0 \leq Y \leq 1/5) =\) 0.001

  1. A friend claim that she has drawn a random sample of size 30, from the exponential distribution with \(\lambda = 1/10\). The mean of her sample is 12.

    1. What is the expected value of a sample mean?
    2. Run a simulation by drawing 10,000 random samples, each of size 30, from \(\text{Exp}(\lambda = 1/10)\) and then compute the mean. What proportion of the sample means are as large as or larger than 12?
    3. Is a mean of 12 unusual for a sample of size 30 from \(\text{Exp}(\lambda = 1/10)\)?
library(tidyverse)
set.seed(123)
n <- 10^4 - 1
result <- numeric(n)
for(i in 1:n){
  result[i] <- mean(rexp(30, 1/10))
}
mean(result)
[1] 9.970705
mean(result >= 12)
[1] 0.1340134
library(ggplot2)
ggplot(data = data.frame(x = result), aes(x = x)) +
  geom_density() + 
  stat_function(fun = dgamma, args = list(30*1, 30/10), color = "blue") +
  theme_bw()

The expected value of the sample mean is \(1/\lambda\), which is \(1/(1/10)\). The sample mean is 9.971 and the proportion of sample means that are greater than or equal to 12 is 0.134. Because 0.134 is greater than 0.05, we have no evidence to suggest that a mean of 12 is unusual for a sample of size 30 from \(\text{Exp}(\lambda = 1/10)\).

  1. Let \(X_1, X_2, \ldots , X_{10} \overset{i.i.d}\sim N(20, 8)\) and \(Y_1, Y_2, \ldots, Y_{15} \overset{i.i.d}\sim N(16, 7)\). Let \(W = \bar{X} + \bar{Y}.\)

    1. Give the exact sampling distribution of \(W\)
      \(W = \bar{X} + \bar{Y} \sim N(36, 3.11^2)\)
    2. Simulate the sampling distribution in R and plot your results. Check that the simulated mean and standard error are close to the theoretical mean and standard error.
# part b
n <- 10^4 - 1
x <- numeric(n)
y <- numeric(n)
for(i in 1:n){
  x[i] <- mean(rnorm(10, 20, 8))
  y[i] <- mean(rnorm(15, 16, 7))
}
W <- x + y
hist(W)

mean(W)
[1] 35.96297
sd(W)
[1] 3.094161
foo <- sqrt(8^2/10 + 7^2/15)
  1. Use your simulation to find \(P(W < 40).\) Calculate an exact answer and compare.
# part c.
mean(W < 40)
[1] 0.9033903
#exact:
pnorm(40, 36, foo)
[1] 0.9008718

P(W<40) = 0.9008718

  1. Let \(X_1, X_2, \ldots , X_{9} \overset{i.i.d}\sim N(7, 3)\) and \(Y_1, Y_2, \ldots, Y_{12} \overset{i.i.d}\sim N(10, 5)\). Let \(W = \bar{X} - \bar{Y}.\)

    1. Give the exact sampling distribution of \(W\). \(W \tilde{} N(-3, sqrt(3^2/9 + 5^2/12))\)
    2. Simulate the sampling distribution of \(W\) in R and plot your results using ggplot2. Check that the simulated mean and the standard error are close to the theoretical mean and the standard error.
    3. Use your simulation to find \(P(W < -1.5)\). Calculate an exact answer and compare.
# part b.
n <- 10000
x <- numeric(n)
y <- numeric(n)
for(i in 1:n){
  x[i] <- mean(rnorm(9, 7, 3))
  y[i] <- mean(rnorm(12, 10, 5))
}
result <- x - y
ggplot(data = data.frame(x = result), aes(x = x)) +
  geom_density() + 
  geom_vline(xintercept = mean(result), color="red") +
  geom_vline(xintercept=-3, color="blue") +
  geom_vline(xintercept=sd(result), color="yellow") +
  geom_vline(xintercept=1.76, color="green") +
  theme_bw()

mean(result)
[1] -2.989098
sd(result)
[1] 1.785281
# part c.
# simulated answer
mean(result < -1.5)
[1] 0.7967
# Exact answer
pnorm(-1.5, -3, sqrt(3^2/9 + 5^2/12))
[1] 0.8035146
  1. Let \(X_1, X_2, \ldots , X_n\) be a random sample from \(N(0, 1)\). Let \(W = X_1^2 + X_2^2 + \cdots + X_N^2.\) Describe the sampling distribution of \(W\) by running a simulation, using \(n = 2.\) What is the mean and variance of the sampling distribution of \(W\)? Repeat using \(n = 4, n = 5.\) What observations or conjectures do you have for general \(n\)?
# Your code here
  1. Let \(X\) be a uniform random variable on the interval \([40, 60]\) and \(Y\) a uniform random variable on \([45, 80].\) Assume that \(X\) and \(Y\) are independent.

    1. Compute the expected value and variance of \(X + Y.\)
    2. Simulate the sampling distribution of \(X + Y.\) Desribe the graph of the distribution of \(X + Y\). Compute the mean and variance of the sampling distribution and compare this to the theoretical mean and variance.
    3. Suppose the time (in minutes) Jack takes to complete his statistics homework is \(\text{Unif}[40, 60]\) and the time JIll takes is \(\text{Unif}[40, 60].\) Assume they work independently. One day they announce that their total time to finish an assignment was less than 90 min. How likely is this?
# Your code here

\(P(X + Y < 90) =?\)

# part c
# P(W < 90)