# # 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. # #----- m1 = 1 sigma1 = 1./2 N = 3 erfc = function(x) { return( 1 - pnorm(x) ) } gamma = seq( from=-40, to=40, length.out=200 ) # # Part (1): # P_F = erfc( gamma * sigma1 / ( sqrt(N) * m1 ) ) P_D = erfc( gamma * sigma1 / ( sqrt(N) * m1 ) - sqrt( N ) * m1 / sigma1 ) #postscript("../../WriteUp/Graphics/Chapter2/prob_2.2.20_part_1.eps", onefile=FALSE, horizontal=FALSE) plot( P_F, P_D, col="black", type="l", xlim=c(0,1), ylim=c(0,1) ) lines( gamma, gamma, col="gray", type="l" ) #dev.off() # # Part (2): # sigma_n = 1 sigma_s = 2 N = 3 gamma = seq( from=-60, to=40, length.out=200 ) gamma_star_F = ( 2*(sigma_s^2 + sigma_n^2)/sigma_s^2 ) * gamma P_F = ( 1 - pchisq( gamma_star_F, N ) ) gamma_star_D = ( 2*sigma_n^2/sigma_s^2 ) * gamma P_D = ( 1 - pchisq( gamma_star_D, N ) ) #postscript("../../WriteUp/Graphics/Chapter2/prob_2.2.20_part_2.eps", onefile=FALSE, horizontal=FALSE) plot( P_F, P_D, col="black", type="l", xlim=c(0,1), ylim=c(0,1) ) lines( gamma, gamma, col="gray", type="l") #dev.off()