1) State the fundamental question of inference

How does what we observe compare to what would happen if the null hypothesis were true and you repeat the process many number of times?

2A)

funcE <- function(x){
  lambda <- (1/5)
  x*(lambda*exp(-lambda*x))
}

E_x <- integrate(funcE, lower = 0, upper = Inf)$value
E_x
## [1] 5
E_xhat <- integrate(funcE, lower = 0, upper = Inf)$value
E_xhat
## [1] 5
funcV <- function(x){
  lambda <- (1/5)
  ((x - E_x)^2)*(lambda*exp(-lambda*x))
}

V_x <- integrate(funcV, lower = 0, upper = Inf)$value
V_x
## [1] 25
V_xhat <- integrate(funcV, lower = 0, upper = Inf)$value
V_xhat
## [1] 25

2B)

sims  <- 10^4 -1
X <- numeric(sims)

for (i in 1:sims) {
  X[i] <- mean(rexp(25, rate = 1/5))
}

E_xbar <- mean(X)
E_xbar
## [1] 4.989852
V_xbar <- var(X)
V_xbar
## [1] 1.011517

2C)

P <- (sum(X >= 7) + 1) / (sims + 1) 
P
## [1] 0.0337