#### verify Ex7.7.7(b) ## verify the density function n <- 10 # sample size xbar <- 1 # sample mean S <- 2 # sample standard deviation x1 <- xbar - (n-1)*S/sqrt(n) # left end of x1 given xbar and S x2 <- xbar + (n-1)*S/sqrt(n) # right end of x1 given xbar and S xf <- function(x) { # density function of x1 given xbar and S gamma((n-1)/2)/(gamma(1/2)*gamma(n/2-1))*sqrt(n)/((n-1)*S)*(1-((x-xbar)/((n-1)*S/sqrt(n)))^2)^(n/2-2); } integrate(xf, lower=x1, upper=x2) # it should give us 1 as the total probability ## verify the MVUE n <- 10 # sample size theta1 <- 1 # mean of normal population theta2 <- 4 # variance of normal population X <- rnorm(n, mean=theta1, sd=sqrt(theta2)) # simulate a random sample form N(theta1, theta2) xbar <- mean(X) # sample mean S <- sqrt(var(X)) # sample standard deviation fmle <- function(c) { # mle for P(X