import math
from math import sqrt,erf,erfc
Vs_Vn=4 #SNVR
a=erf(4/sqrt(2))
b=erfc(4/sqrt(2))*10**5
Pbe=(0.5)*(b) #bit error probability
a=round(a,2)
b=round(b,2)
print 'a=',a
print 'b=',b,'*10**-5'
Pbe=round(Pbe,2)
print 'The bit error probability',Pbe,'*10**-5'
import math
A=4 #max value of received signal voltage
Vn=0.5 #rms noise voltage
Vth=2 #Threshold voltage for the comparator
b=erfc(Vn/sqrt(2))
Pbe=(0.5) * b #bit error probability
Pbe=round(Pbe,3)
print 'The bit error probability',Pbe
import math
from math import erfc
SNR=9.0 #SNR in dB
#conversion of dB to power ratio
p=10**(9/10) #for Polar
Pbe1=0.5*erfc(sqrt(7.94/2))
Pbe1=round(Pbe1,4)
print 'Bit Probabilty,Pbe1=',Pbe1
#for Unipolar
Pbe2=0.5* erfc(sqrt(7.94)/2)
Pbe2=round(Pbe2,4)
print 'Bit Probability,Pbe2=',Pbe2
import math
Pavg=6.0*10**-12 #in W
d=0.02*10**-6 #pulse duration in sec
T=550.0 #equivalent noise temp in K
Eb=Pavg*d #avg energy per pulse
No=1.38*10**-23*T
r=Eb/No #Bit error probability is
Pbe=0.5*erfc(sqrt(r/2))*10**5
Pbe=round(Pbe,1)
print 'The bit error probability',Pbe,'*10**-5'
import math
from math import exp
ENR=10.0 #energy to noise density ratio
Pbe1=0.5* erfc(sqrt(ENR/2))
Pbe1=round(Pbe1,5)
print 'a)The bit error probability',Pbe1
Pbe2=(0.5)*exp(-(ENR/2))
Pbe2=round(Pbe2,5)
print 'b)The bit error probability',Pbe2
import math
Pbec=0.01
n=8.0
i=3.0
Pi=(Pbec**i)*((1-(Pbec))**(n-i))
Cin=(math.factorial(n))/(math.factorial(i)*math.factorial(n-i))
Pin=Cin*Pi*10**5
P_in=Cin*Pbec**i*10**5
Pin=round(Pin,2)
P_in=round(P_in,2)
print 'The probability of a received codeword',Pin,'*10**5'
print 'P_in=',P_in,'*10**5'
import math
from math import sqrt,erf
SN_dB=9
SNR=10**(SN_dB/10)
PbeU=0.5 * (1-erf(sqrt(SNR)))
BERu=PbeU
BERu=round(BERu,3)
print 'a)The bit error probability',BERu
n=10
k=n-1
r=k/n
SNR1=r*SNR
PbeC=0.5 *(1-erf(sqrt(SNR1)))
BERc=(n-1)*PbeC**2
print 'b)The bit error probability',BERc
import math
from math import sqrt
SN_dB=8
SNR=10**(SN_dB/10) #a) Determination of bit error rate
PbeU=0.5*(1-erf(sqrt(SNR)))
BER_U=PbeU
BER_U=round(BER_U,3)
print 'a)The bit−error rate is',BER_U
#b)new bit error rate
n=15
k=11
t=1
r=k/n
SNR_n=r*SNR
PbeC=0.5*(1-erf(sqrt(SNR_n)))
BER_C=((math.factorial(n-1))*PbeC**(t+1))/((math.factorial(t)) *(math.factorial(n-t-1)))
print 'b)The new bit error rate is',BER_C