# Questions on EPage 394 # # Question 3: # data = c( 65, 30, 55 ) z = ( data - 50 ) / 10 print( 1-pchisq( sum( z^2 ), 3 ) ) # Question 6: # n = 200 print( n + sqrt(2*n) * qnorm(0.4) ) # Question 7: # pt_a = qf(0.5, 6, 7) pt_b = qf(0.001, 15, 5) pt_c = qf(0.9, 2, 2) ans = c( pt_a, pt_b, pt_c ) print(ans) # Question 8: # pt_1 = pf( 3.29, 7, 9) - pf( 2.51, 7, 9) pt_2 = pf( 4.2, 7, 9 ) - pf( 3.29, 7, 9) print( c( pt_1, pt_2 ) ) # Question 9: # pt_a = qf( 0.95 + pf( 0.109, 4, 6 ), 4, 6 ) pt_b = pf(1.69, 11, 7) - pf(0.427, 11, 7) library(stats) qf_root = function(x){ qf(0.99, x, x) - 5.35 } res = uniroot( qf_root, c(5, 10) ) pt_c = res$root qf_root = function(x){ pf(3.29, 3, x) - pf(0.115, 3, x) - 0.9 } res = uniroot( qf_root, c(10, 20) ) pt_d = res$root pt_e = qf( 1-0.25, 2, 3 ) ans = c( pt_a, pt_b, pt_c, pt_d, pt_e ) print(ans) # Question 12: # print( c( qf( 0.05, 2, 8 ), 1/qf( 0.95, 8, 2 ) ) ) print( c( qf( 0.95, 2, 8 ), 1/qf( 0.05, 8, 2 ) ) )