# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- # Problem 1 (epage 152): # Xbar = 78 mu = 80 sigma = 5 n = 10 Z = ( Xbar - mu)/(sigma/sqrt(n)) alpha = 0.05 c = qnorm( alpha ) # Problem 2-3 (epage 152): # c = qnorm( 1 - 0.5*alpha ) Xbar - c * sigma/sqrt(n) Xbar + c * sigma/sqrt(n) # Problem 4-5 (epage 152): # c = ( Xbar - mu)/(sigma/sqrt(n)) p = pnorm( c ) p = 2 * pnorm( c ) # Problem 6-7 (epage 152): # xbar = 120 sigma = 5 n = 49 alpha = 0.05 mu = 130 Z = ( xbar - mu )/(sigma/sqrt(n)) c = qnorm(alpha) if( Z < c ){ print("reject H_0") }else{ print("cannot reject H_0") } c = -qnorm(0.5*alpha) # for a two-sided test xbar - c * sigma/sqrt(n) xbar + c * sigma/sqrt(n) # Problem 10 (epage 153): # mu = 232 xbar = 240 sigma = 4 n = 25 alpha = 0.01 Z = ( xbar - mu )/(sigma/sqrt(n)) c = -qnorm( alpha ) if( Z <= c ){ print("cannot reject H_0") }else{ print("must reject H_0") } # Problem 11 (epage 153): # xbar = 565 mu = 546 sigma = 40 n = 20 alpha = 0.05 Z = ( xbar - mu )/(sigma/sqrt(n)) c = qnorm( 1 - 0.5*alpha ) xbar - c * sigma/sqrt(n) # the confidence interval xbar + c * sigma/sqrt(n) # Problem 13 (epage 153): # alpha = 0.01 c = qnorm( alpha ) n = 25 mu = 56 mu_0 = 60 sigma = 5 pnorm( c - ( sqrt(n)*( mu - mu_0 ) )/sigma ) # Problem 14 (epage 153): # alpha = 0.025 c = qnorm( 1 - alpha ) n = 36 mu = 103 mu_0 = 100 sigma = 8 1 - pnorm( c - ( sqrt(n)*( mu - mu_0 ) )/sigma ) # Problem 15 (epage 153): # Not sure that this is correct??? # alpha = 0.05 c1 = qnorm( 0.5*alpha ) c2 = qnorm( 1 - 0.5*alpha ) n = 49 mu = 47 mu_0 = 50 sigma = 10 pnorm( c1 - sqrt(n)*abs( mu - mu_0 )/sigma ) pnorm( -c2 - sqrt(n)*abs( mu - mu_0 )/sigma ) # Problem 16,17,18 (epage 153): # alpha = 0.05 xbar = 46 mu = 48 n = 10 sigma = 5 Z = ( xbar - mu )/( sigma/sqrt(n) ) c = qnorm( alpha ) mu_0 = 48 # this is the mean we are trying to refute mu = 46 # the true mean is this pnorm( c - ( sqrt(n)*(mu-mu_0)/sigma ) ) ns = c(20,30,40) pnorm( c - ( sqrt(ns)*(mu-mu_0)/sigma ) ) # Problem 20: # alpha = 0.05 n = 25 mu_0= 42 c = qt(1-0.5*alpha,n-1) # 2.063899 # Part a: # x_bar = 44 s = 10 T = ( x_bar - mu_0 ) / ( s/sqrt(n) ) if( abs(T)>c ){ print("reject H_0"); }else{ print("cannot reject H_0"); } # Part b: # x_bar = 43 s = 10 T = ( x_bar - mu_0 ) / ( s/sqrt(n) ) if( abs(T)>c ){ print("reject H_0"); }else{ print("cannot reject H_0"); } # Part c: # x_bar = 43 s = 2 T = ( x_bar - mu_0 ) / ( s/sqrt(n) ) if( abs(T)>c ){ print("reject H_0"); }else{ print("cannot reject H_0"); } # Problem 22: # alpha = 0.05 n = 16 mu_0= 42 c = qt(1-alpha,n-1) # Part (a): # x_bar = 44 s = 10 T = ( x_bar - mu_0 )/( s/sqrt(n) ) if( T > c ){ print("we reject H_0"); }else{ print("we cannot reject H_0") } # Part (b): # x_bar = 43 s = 10 T = ( x_bar - mu_0 )/( s/sqrt(n) ) if( T > c ){ print("we reject H_0"); }else{ print("we cannot reject H_0") } # Part (c): # x_bar = 43 s = 2 T = ( x_bar - mu_0 )/( s/sqrt(n) ) if( T > c ){ print("we reject H_0"); }else{ print("we cannot reject H_0") } # Problem 23: # alpha = 0.05 n = 16 mu_0= 42 c = qt(alpha,n-1) # Part (a): # x_bar = 44 s = 10 T = ( x_bar - mu_0 )/( s/sqrt(n) ) if( T < c ){ print("we reject H_0"); }else{ print("we cannot reject H_0") } # Part (b): # x_bar = 43 s = 10 T = ( x_bar - mu_0 )/( s/sqrt(n) ) if( T < c ){ print("we reject H_0"); }else{ print("we cannot reject H_0") } # Part (c): # x_bar = 43 s = 2 T = ( x_bar - mu_0 )/( s/sqrt(n) ) if( T < c ){ print("we reject H_0"); }else{ print("we cannot reject H_0") } # Problem 24: # data = c(38, 44, 62, 72, 43, 40, 43, 42, 39, 41) xbar = mean(data) s = sqrt(var(data)) n = length(data) alpha = 0.05 c = qt( 1 - 0.5*alpha, n-1 ) mu_0 = 45 T = ( xbar - mu_0)/( s/sqrt(n) ) if( abs(T)>c ){ print("we reject H_0") }else{ print("we cannot reject H_0") } # Problem 25: # xbar = 9.79 s = 2.71 n = 100 alpha = 0.025 c = qt( alpha, n-1 ) mu_0 = 10.5 T = ( xbar - mu_0)/( s/sqrt(n) ) if( Tc ){ print("we reject H_0") }else{ print("we cannot reject H_0") } # Problem 27: # I think there is a typo in this problem # xbar = 76 s = 4 n = 9 alpha = 0.05 c = qt( 1-0.5alpha, n-1 ) mu_0 = 72 T = ( xbar - mu_0 )/( s/sqrt(n) ) if( abs(T)>c ){ print("we reject H_0") }else{ print("we cannot reject H_0") } # Problem 28: # xbar = 146 s = 2.5 n = 10 alpha = 0.05 c = qt( 1-0.5*alpha, n-1 ) mu_0 = 150 T = ( xbar - mu_0 )/( s/sqrt(n) ) if( abs(T)>c ){ print("we reject H_0") }else{ print("we cannot reject H_0") } # Problem 29: # data = c(42,90,84,87,116,95,86,99,93,92,121,71,66,98,79,102,60,112,105,98) xbar = mean(data) s = sqrt(var(data)) n = length(data) alpha = 0.01 c = qt( 1-alpha, n-1 ) mu_0 = 80 T = ( xbar - mu_0 )/( s/sqrt(n) ) if( T>c ){ print("we reject H_0") }else{ print("we cannot reject H_0") } # Problem 30: # xTrimmedMean = 44 xTrimmedMean = 43 sw = 9 mu_t = 42 alpha = 0.05 n = 20 # get the amount of trimming h: h = 2*floor(0.2*n) c = qt(1-0.5*alpha,n-h-1) T_t = 0.6*(xTrimmedMean - mu_t)/(sw/sqrt(n)) # Problem 31 # #Part (a): xTrimmedMean = 44 sw = 9 mu_t = 42 alpha = 0.05 n = 16 # get the amount of trimming h: h = 2*floor(0.2*n) T_t = 0.6*(xTrimmedMean - mu_t)/(sw/sqrt(n)) c = qt(1-alpha,n-h-1) #Part (b): xTrimmedMean = 43 T_t = 0.6*(xTrimmedMean - mu_t)/(sw/sqrt(n)) #Part (c): xTrimmedMean = 43 sw = 3 T_t = 0.6*(xTrimmedMean - mu_t)/(sw/sqrt(n)) # Problem 32 # xTrimmedMean = 42.17 sw = 1.73 n = 10 mu_t = 45 T_t = 0.6*(xTrimmedMean - mu_t)/(sw/sqrt(n)) h = 2 * floor(.2*n) alpha = 0.05 c = qt( 1 - 0.5*alpha, n - h - 1 ) # Problem 33 # mu_t = 4.8 xTrimmedMean = 5.1 sw = 7 n=25 alpha = 0.01 h = 2*floor(0.2*n) c = qt( 1 - 0.5*alpha, n - h - 1 ) T_t = 0.6*( xTrimmedMean - mu_t )/( sw/sqrt(n) )