from numpy import sqrt,pi
from mpmath import quad
#Given
mue=25#
rp=5e3
Rl=10e3
C=1e-9
gm=mue/rp
Req=2.5/gm
k=1.381e-23
T=293
R1=1e5
# Power density spectrum for respective res
d1=2*k*T*R1
d2=2*k*T*Req
d3=2*k*T*Rl
xo=0
x1=1e14
#w=0:inf
#H1(w)=(-gm*rp*Rl)/(rp+Rl+(1J*w*rp*Rl*C))
Vo=sqrt((20231.65e2/pi)*quad(lambda w:1/(((3e9)**2)+(w**2)),[xo,x1]))
print 'The mean square noise voltage is: %0.3f mV'%(Vo*1e3)
from numpy import sqrt,pi
from mpmath import quad
#Given
mue=25
rp=5e3
Rs=1e3#input resistance
#Coupling Capacitors are assumed as short circuit
Rg=1e5
gm=25/5e3
Req=2.5/gm
F=1+((((Req*(Rs+Rg)**2)+(Rg*Rs**2))/(Rs*Rg**2)))
xo=0
x1=1e10
#w=0:inf
vo=sqrt((30145e-8/pi)*quad(lambda w:1/(((3e5)**2)+(w**2)),[xo,x1]))
print 'The mean square noise voltage is: %.3f uV'%(vo*1e6)
from __future__ import division
#Given
Ap1=10
Ap2=10
Ap3=10# # Gain of each states
F_1=6
F_2=6
F_3=6# #Noise figure of each state
F1= round(10**(F_1/10))
F2= round(10**(F_2/10))
F3= round(10**(F_3/10))# # approximating the values
F=F1+((F2-1)/Ap1)+((F3-1)/(Ap1*Ap2))
print 'overall noise Figure is: %.2f'%(F)
from __future__ import division
#Given
Fif=15# Noise figure of IF amplifier
Ap1=10# Gain of Preamplifier
Fpa=6#Noise figure of preamplifier
F2=10**(Fif/10)
F1=10**(Fpa/10)
F=F1+((F2-1)/Ap1)#overall noise figure
print 'The overall noise figure is: %.2f'%(F)
from __future__ import division
#Given
mue=25# tube parameters
rp=10e3# tube parameters
gm=2.5e-3# transconductance
Req=2.5/gm# equivalent resistance
Rs=1000
Rg=1e5
F1=1+(((Req*((Rs+Rg)**2))+Rg*Rs**2)/(Rs*(Rg**2)))#noise figure of the first stage
Rg2=9.1e3
Rs2=10e3
Es=1# assuming Es=1 for ease of calculation
Pi=((Es/2e3)**2)*1e3
Po=1.532e-2*Es**2
Ap1=Po/Pi
F2=1+(((Req*((Rs2+Rg2)**2))+Rg2*Rs2**2)/(Rs2*(Rg2**2)))# noise figure of the second stage
F=(F1)+((F2-1)/Ap1)
print 'Overall Noise figure is: %.3f'%(F)
from __future__ import division
#Given
g01=30# gain of 1st stage
g02=20#gain of 2nd stage
g03=40#gain of 3rd stage
F2=6# Noise factor of stage 2
F3=12# Noise factor of stage 3
Te1=4# Eq noise temp of stage 1
T=290# Room
G01=round(10**(g01/10))
G02=round(10**(g02/10))
G03=round(10**(g03/10))
F_2=round(10**(F2/10))
F_3=round(10**(F3/10))
Te2=round((F_2-1))*T
Te3=round((F_3-1))*T
Te=Te1+(Te2/G01)+(Te3/(G01*G02))# Eq overall noise temp
print 'The equivalent noise temp is: %.3f K'%(Te)
from __future__ import division
#Given
g01=round(10**(25/10))#low noise amplifier gain
Te1=4#low noise amplifier noise temp
g02=round(10**(1.7))#preamplifier gain
F2=round(10**0.6)#preamplifier noise figure
F3=round(10**1.2)#preamplifier noise figure
T=290# room temp
Te2=round((F2-1)*T)
Te3=round((F3-1)*T)
Te=Te1+(Te2/g01)+(Te3/(g01*g02))#Overall noise Temperature
print 'Equivalent noise temperature is %.3f K'%(Te)
from __future__ import division
from math import log10
#Given
SNRam=25# Signal to noise ratio of AM
PcFM_AM=0.9#
mf=5
SNRfm=(10*log10(3*(mf**2)*(PcFM_AM)))+SNRam
print 'S/N ratio for FM is %.2f dBs'%(SNRfm)
# Note : There are some calculation errors in the solution presented in the book
from __future__ import division
from math import log10
#Given
ma=0.3
SNR=20# s/n ratio
SNR1=10**(0.1*SNR)
SNR_new=SNR+3
ma2=0.6# increased new depth of modulation
Pt_Ni=SNR1*((1+(ma**2))/(ma**2))
SNR2=10*log10(Pt_Ni*((ma2**2)/(1+((ma2**2)/2))))
print 'a)\n New SNR for 3dB increase in input s/g is %d dBs\nb) When Modulation depth is increased to 60%%\n SNR becomes %f dBs'%(SNR_new,(SNR2))
from __future__ import division
from math import log
#Given
fmax=5e3#max s/g freq
S_fmin=2*fmax# Min sampling freq
B_S=6#Binary bits sent per sample
BTR=B_S*S_fmin#Bit Transmission rate
Q=2**B_S#No of Quantizable levels
MQN=0.5/Q#Max Quantization noise
S_QNR=MQN**-1# Signal to Quantization noise ratio
#b
S_QNRreq=0.5*S_QNR# Signal to Quantization noise ratio
Qreq=0.5*S_QNRreq#No of Quantizable levels
B_Sreq=log(Qreq,2)#Binary bits sent per sample
print 'a) Bit Transmission rate: %d kbits/s\n Signal to Quantization noise ratio %d \nb)\n Bit Transmission rate: %d kbits/sample\n Signal to Quantization noise ratio: %d'%(BTR/1000,S_QNR,B_Sreq,S_QNRreq)