#Variable Declaration
BER=10**-5 #Maximum allowable bit error rate
#Calculation
import math
from pylab import*
%matplotlib inline
x=linspace(8,10,11) #Eb/N0 ratio represented by x
x1=x**0.5
for i in range(0,11):
x[i]=10*math.log10(x[i]) #Converting x into decibels
erf=linspace(0,0,11) #Initialization for erf function
Pe=linspace(0,0,11) #Initialization for Probablity of error
from scipy import integrate
f=lambda t:math.exp(-t**2)
for i in range(0,10):
k=integrate.quad(f,0,x1[i])
erf[i]=k[0]*(2/math.pi**0.5)
Pe[i]=(1-erf[i])/2 #Probability of error
y=linspace(9,9.59,5)
z=linspace(BER,BER,5)
a=linspace(9.59,9.59,5)
b=linspace(0,BER,5)
plot(x,Pe)
plot(y,z)
plot(a,b)
xlabel('xdB')
ylabel('Pe(x)')
show()
x=9.6 #The Eb/N0 ratio for Maximum BER(dB) from the graph
EbN0=x+2 #Eb/N0 ratio with implementation margin
#Results
print "The Eb/N0 ratio with allowable BER of 10^-5 and implementation margin of 2dB is",EbN0,"dB"