Make fake timeseries.

The first will just be a Gaussian Random variable. The second will be a random walk.

In [84]:
import numpy as np    # import the numpy module

N=1000
time=np.arange(0,N,1.)  # make a fake time variable
y1 = np.random.randn(N) # make a fake random variable.  This is "white noise"
y2 = np.cumsum(np.random.randn(N)) # make a fake random variable by integrating
y2=y2-y2.mean()
y2=y2/y2.std()
y3=y2*1. # make a copy
np.random.shuffle(y3) # shuffling happens in place

np.savetxt('resources/Lesson00/FakeData.txt',(time,y2,y3))
In [83]:
import urllib
url="https://github.com/jklymak/Phy411/raw/master/lectures/resources/Lesson00/FakeData.txt"
f=urllib.urlopen(url)
dat=np.loadtxt(f)
print shape(dat)
time=dat[0,:]
y2=dat[1,:]
y3=dat[2,:]
(3, 20000)
In [85]:
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec

plt.figure(figsize=(7,4))
gs=gridspec.GridSpec(1,3)
ax1=plt.subplot(gs[0:2])
ax1.plot(time,y3,label='$y_1$')
ax1.plot(time,y2,label='$y_2$')
ax1.set_xlabel('Time [s]')
ax1.set_ylabel('Data')
ax1.legend()

ax2=plt.subplot(gs[2])
n3,edges3=np.histogram(y3,bins=50,density=True)
n2,edges2=np.histogram(y2,bins=50,density=True)
ax2.step(n3,edges3[:-1],where='pre')
ax2.step(n2,edges2[:-1])
ax2.set_xlabel('PDF')
#ax2.step()
#np.histogram()
plt.tight_layout()

Dates:

03,05, 09,10,12, 16,18,19, 23,25,26, 30,

01,03, 07,08,10, 14,15,17, 21,22,24, 28,29,31,

04,05,07, ,14, 18,19,21, 25,26,28,

02,03

In [ ]: