import math
#Signal Power data rate fb = 100 Kbps
fb = 10.**5;
#Signal Strength Ps = 1 mW
Ps = 1*10.**(-3);
#Chip frequency fs = 100 MHz
fs = 10.**8;
#Noise Spectral Density n = 2*10**(-9) W/Hz
n = 2*10.**(-9);
#Jamming Signal power is Pj = 1 W
Pj = 1.;
#Procesmath.sing Gain P
P = fs/fb;
print 'Procesmath.sing Gain is ',P
#Bit Interval T
T = 1/fb;
print 'Bit Interval is ',T,'s'
#Energy per bit Eb
Eb = Ps*T;
print 'Energy per bit is ',Eb
#Error Probability without jamming E_without_jamming
E_without_jamming = 0.5*math.erfc((Eb/(n))**0.5);
print 'Error probability without jamming is %.4f'%E_without_jamming
#Error Probability with jamming E_jamming
E_jamming = 0.5*math.erfc(((2*Ps*P)/(Pj))**0.5);
print 'Error probability jamming is %.4f'%E_jamming
#Chip Rate fc = 110 MHz
fc = 10*10**6;
Tc = 1./fc;
#Delay D = 0.1 ms
D = 0.1*10**-3;
#Speed of light c = 3*10**8 Kmps
c = 3*10**8;
#Estimated Dismath.tance d
d = 0.5*c*D;
#Tolerance Tol
Tol = 0.5*c*Tc;
print 'The target is between ',d-Tol,' metres and ',d+Tol,' metres of the source.'
#Number of Flip Flops N
N = 13.;
#Maximal length of sequence L
L = 2**N - 1;
#Upper Bound S
S = (L - 1)/N;
#No of basic sequences and mirror images
print 'No of basic sequences and mirror images is ',S/2