# # 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. # #----- sigma_n = 1 sigma_b = 2 m_1 = 5 erfc = function(x) { return( 1 - pnorm(x) ) } gamma = seq( from=0, to=20, length.out=200 ) P_F = 2 * erfc( gamma/sigma_n ) P_D = 2 * erfc( gamma/sqrt( (m_1*sigma_b)^2 + sigma_n^2 ) ) #postscript("../../WriteUp/Graphics/Chapter2/prob_2.2.6.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" ) # Evaluate the minimum probability of error operating point: # tot_var = m_1^2 * sigma_b^2 + sigma_n^2 gamma_mpe = ( ( 2 * tot_var * sigma_n^2 )/( m_1^2 * sigma_b^2 ) ) * log( sqrt( tot_var/sigma_n^2 ) ) print( gamma_mpe) P_F_mpe = 2 * erfc( gamma_mpe/sigma_n ) P_D_mpe = 2 * erfc( gamma_mpe/sqrt( (m_1*sigma_b)^2 + sigma_n^2 ) ) lines( P_F_mpe, P_D_mpe, col="red", type='o', pch=10, cex=1.5 ) Pr_error = 0.5 + 0.5 * ( P_F_mpe - P_D_mpe ) print(Pr_error) #dev.off()