problem-8.16

problem-8.16  We do this all at once using a list for storage
> lst = list()
> m = 250; n = 10
> for(i in 1:m) {
+ lst$exp[i]  = t.test(rexp(n),     mu=1,  df=n-1)$p.value
+ lst$unif[i] = t.test(runif(n),    mu=.5, df=n-1)$p.value
+ lst$t4[i]   = t.test(rt(n, df=4), mu=0,  df=n-1)$p.value
+ }
> sapply(lst, function(x) sum(x<0.05)/length(x))
  exp  unif    t4
0.088 0.052 0.044
      
When the population distribution is skewed, the sampling distribution of T may differ a lot from the t-distribution.