### This is a program by Brant Balgooyen. ### Consider sampling from a normal population with mean mu = 100 and ### standard deveiation sigma = 10. The hypothesis test H0: mu = 10 ### versus HA: mu not = 10 is tested. If the t-test works correctly the ### Type I Error (alpha) should be 0.05. ####################################################################### mu_100 # population mean sigma_10 # population standard deviation Count_0 M_1000 # number of samples taken alpha_.05 # size of the test pvector_c() # initialize a vector for(i in 1:M) { x_rnorm(30,mu,sigma) t.output_t.test(x, mu=mu) pvalue_t.output$p.value pvector_c(pvector, pvalue) if (pvalue < alpha) Count_Count + 1 } alpha.est_Count/M print(alpha.est) hist(pvector)