In [19]:
from numpy import *
%pylab inline
import subprocess
Populating the interactive namespace from numpy and matplotlib

P1

P2

P3

In [8]:
eps = linspace(0,1,100)
plot(eps, eps**3 + 3*eps**2 * (1-eps))
plot(eps, 3*eps**2)
ylim([0,1])
Out[8]:
(0, 1)

P4

P5

In [76]:
from math import log
def c(snr,df,approx=False):
    #snr: signal power to noise power ratio, decibels
    #df: bandwidth
    #whether to approximate, only good for large snr
    if approx:
        return df*( snr/10./log(2,10) - log(df,2) )
    else:
        return df*log(1.+( 10**(snr/10.) )/df , 2)
print "The channel capacity of a standard phone line is %.2f bits per second."%c(20.,3300.)
new_snr = 1e6
print "With a SNR of %.1e dB, the channel capacity would be %.3f Gbits per second."%(new_snr,c(new_snr,3300.,approx=True)*1.e-9)
The channel capacity of a standard phone line is 142.13 bits per second.
With a SNR of 1.0e+06 dB, the channel capacity would be 1.096 Gbits per second.

P6

In [18]:
import sympy as sym
x = sym.Symbol('x')
x0 = sym.Symbol('x0')
s = sym.Symbol('s',positive=True)

def p(x0,x,s):
    return 1/sym.sqrt(2*sym.pi*s**2)*sym.exp(-(x-x0)**2/(2*s**2) )

print sym.simplify( sym.integrate( p(x0,x,s) * (x-x0)**2, (x, -sym.oo, sym.oo) ) )

print sym.simplify( sym.integrate( p(x0,x,s) * x**2, (x, -sym.oo, sym.oo) ) )
s**2
s**2 + x0**2
In [ ]: