In [ ]:
%matplotlib inline
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import numpy.linalg as la
In [ ]:
plt.rcParams['figure.figsize'] = (24.0, 16.0)
In [ ]:
gen = (2*n for n in range(10))
In [ ]:
for i in gen:
print i
In [ ]:
def y_itr(x_itr):
# Force first y to be 0, ignoring x[0]
next(x_itr)
yield 0
prev_x = 0
prev_y = 0
for x in x_itr:
y = x - prev_x/2.0 - 2*prev_y
yield y
prev_x = x
prev_y = y
In [ ]:
x = [0 for i in range(51)]
x[0] = 1
x[1] = -.5
x_itr = (z for z in x)
In [ ]:
for y in y_itr(x_itr):
print y
In [30]:
def f(omega):
return pow(np.cos(np.pi/4.0*omega),2.0)
omegas = np.arange(-6, 6, 0.1)
Y1s = f(omegas)
Y2s = f(omegas-1)
Ys = Y1s + Y2s
plt.plot(omegas, f(omegas))
plt.plot(omegas, f(omegas-1))
plt.plot(omegas, Ys)
plt.ylabel('X(Omega) axis')
plt.xlabel('Omega axis')
Out[30]:
In [114]:
f0=0
f1=10
t1=2
alpha=(f1-f0)/t1
def clamp(t,c):
return [min(i,c) for i in t]
def chirp(t):
# return np.cos(2*np.pi*f0*t + alpha*np.pi*t*t)
return np.cos(alpha*np.pi*t*clamp(t,100))
ts = np.arange(0, 10, 1.0/50)
chirps = chirp(ts)
print alpha
plt.plot(ts,chirps)
Out[114]:
In [105]:
rands=sp.randn(10000)
In [106]:
plt.hist(rands,100);
In [122]:
def J(theta):
return 2*pow(theta,4) + 2
x = (J(1.01)-J(.99))/.02
In [123]:
x
Out[123]:
In [ ]: