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?
set.seed(123)
pop <- c(3, 6, 7, 9, 11, 14)
Mu <- mean(pop)
Mu
[1] 8.333333
Stdev <- sd(pop)
Stdev
[1] 3.88158
W <- numeric(1000)
S <- numeric(1000)
for(i in 1:1000) {
  X <- rnorm(3, Mu, Stdev)
  W[i] <- mean(X)
  S[i] <- sd(X)
}
mean(W)
[1] 8.383122
mean(S)
[1] 3.423547
  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)\).
cdf <- function(x){(3/8) * x^2}
integrate(cdf, 0, 2)$value
[1] 1
integrate(cdf, 0, 1/5)$value
[1] 0.001

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

  1. A friend claims 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)
# a.
xfx <- function(x){x/10 * exp(-x/10)}
EX <- integrate(xfx, 0, 30)$value
EX
[1] 8.008517
# b. 
sims <- 10^4
Y <- numeric(sims)
for(i in 1:sims){
 Y[i] <- mean(rexp(30, 1/10))
}
mean(Y)
[1] 9.971208
mean(Y >= 12)
[1] 0.1341

It is not unusual to get a mean of 12 in 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\)
    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.
    3. Use your simulation to find \(P(W < 40).\) Calculate an exact answer and compare.

\(W\sim N(36, 3.4157)\)

# b.
sims<- 10^4 
W <- numeric(sims)
for(i in 1:sims){
  X <- rnorm(10, 20, 8)
  Y <- rnorm(15, 16, 7)
  W[i] <- mean(X) + mean(Y)
}
mean(W)
[1] 35.95246
sd(W)
[1] 3.106992
# c.
sims<- 10^4 
W <- numeric(sims)
for(i in 1:sims){
  X <- rnorm(10, 20, 8)
  Y <- rnorm(15, 16, 7)
  W[i] <- X + Y
}
mean(W < 40)
[1] 0.6481
pnorm(39, 36, 3.4157)
[1] 0.8101088
  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\).
    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.

\(W\sim N(-3, 1.756)\)

# part b.
sims <- 10^4 
W <- numeric(sims)
for(i in 1:sims){
  X <- rnorm(9, 7, 3)
  Y <- rnorm(12, 10, 5)
  W[i] <- mean(X) - mean(Y)
}
mean(W)
[1] -3.006878
sd(W)
[1] 1.761563
# part c.
# simulated answer
sims <- 10^4 
W <- numeric(sims)
for(i in 1:sims) {
  X <- rnorm(9, 7, 3)
  Y <- rnorm(12, 10, 5)
  W[i] <- X - Y
}
mean(W < -1.5)
[1] 0.6001
# Exact answer
pnorm(-1.4, -3, 1.756)
[1] 0.8188949
  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\)?
# a.
set.seed(123)
sims <- 10^4 
W <- numeric(sims)
V <- numeric(sims)
for(i in 1:sims) {
  X <- rnorm(2, 0, 1)
  W[i] <- sum(X)
}
mean(W)
[1] -0.01147815
var(W)
[1] 2.002168
# b.
sims <- 10^4 
W <- numeric(sims)
V <- numeric(sims)
for(i in 1:sims) {
  X <- rnorm(4, 0, 1)
  W[i] <- sum(X)
}
mean(W)
[1] 0.01407271
var(W)
[1] 3.97833
# c. 
sims <- 10^4 
W <- numeric(sims)
V <- numeric(sims)
for(i in 1:sims) {
  X <- rnorm(5, 0, 1)
  W[i] <- sum(X)
}
mean(W)
[1] 0.02408073
var(W)
[1] 4.850376

The sampling distribution is approximately normal, so n must be sufficiently large for this distribution.

  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?
# a.
xfx <- function(x){x/20}
EX <- integrate(xfx, 40, 60)$value
yfy <- function(x){x/35}
EY <- integrate(yfy, 45, 80)$value
EX + EY
[1] 112.5
vx <- function(x){
  (x - EX)^2 / 20
}
VX <- integrate(vx, 40, 60)$value
vy <- function(x){
  (x - EY)^2 / 35
}
VY <- integrate(vy, 45, 80)$value
VX + VY
[1] 135.4167
# b.
sims <- 10^4 
result_means <- numeric(sims)
result_var <- numeric(sims)
for(i in 1:sims) {
  X <- runif(sims, 40, 60)
  Y <- runif(sims, 45, 80)
  result_means[i] <- mean(X) + mean(Y)
  result_var[i] <- var(X) + var(Y)
}
mean(result_means)
[1] 112.5002
mean(result_var)
[1] 135.4123

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

# part c
# P(W < 90)
sims <- 10^4 
result <- numeric(sims)
for(i in 1:sims) {
  X <- runif(sims, 40, 60)
  Y <- runif(sims, 40, 60)
  result[i] <- X + Y
}
mean(result < 90)
[1] 0.1166