T1 Assignment
Assignment
Assignment 2 Part 1 Support
(MIPS exercise 20.9) Let X1, . . . , Xn
iid∼ Bernoulli(p) and consider two estimators for p:
T1 = X¯, T2 = min(X1, . . . , Xn)
The MSE for each estimator are
MSE(T1) = p(1− p)/n,MSE(T2) = pn − 2pn+1 + p2
Let’s plot these as a function of p, for different values of n.
# Define a function for both
MSE_T1 <- function(p,n) p*(1-p)/n
MSE_T2 <- function(p,n) p^n - 2*p^(n+1) + p^2
# Write a function to make the plot of p for fixed n
make_plot <- function(n) {
tibble(x = c(0,1)) %>%
ggplot(aes(x = x)) +
theme_bw() +
stat_function(fun = MSE_T1,args = list(n = n)) +
stat_function(fun = MSE_T2,args = list(n = n),linetype = ’dashed’) +
labs(title = paste0("MSE for n = ",n),
subtitle = "T1 (Solid) vs T2 (Dashed)",
x = "p",
y = "MSE"
)
}
library(patchwork)
## Warning: package ’patchwork’ was built under R version 4.0.3
(make_plot(1) | make_plot(5)) /
(make_plot(10) | make_plot(20)) /
(make_plot(50) | make_plot(100))
1
0.000.05
0.100.15
0.200.25
0.00 0.25 0.50 0.75 1.00
p
M
SE
T1 (Solid) vs T2 (Dashed)
MSE for n = 1
0.0
0.1
0.2
0.3
0.4
0.00 0.25 0.50 0.75 1.00
p
M
SE
T1 (Solid) vs T2 (Dashed)
MSE for n = 5
0.0
0.2
0.4
0.6
0.00 0.25 0.50 0.75 1.00
p
M
SE
T1 (Solid) vs T2 (Dashed)
MSE for n = 10
0.0
0.2
0.4
0.6
0.00 0.25 0.50 0.75 1.00
p
M
SE
T1 (Solid) vs T2 (Dashed)
MSE for n = 20
0.0
0.2
0.4
0.6
0.8
0.00 0.25 0.50 0.75 1.00
p
M
SE
T1 (Solid) vs T2 (Dashed)
MSE for n = 50
0.00
0.25
0.50
0.75
0.00 0.25 0.50 0.75 1.00
p
M
SE
T1 (Solid) vs T2 (Dashed)
MSE for n = 100