In [25]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [34]:
nsample = 1000
nstep = 10000
x_arr = np.zeros([nstep,nsample])
myx = np.random.rand(nsample)
for istep in range(nstep):
myx += 0.01*np.random.randn(nsample)
out_sel = (myx<0) | (myx>1)
myx[out_sel] = np.random.rand(len(myx[out_sel]))
x_arr[istep,:] = myx
# end for istep
def free_ground(x):
return np.sin(np.pi*x)*np.pi/2.
finex = np.linspace(0,1,100)
plt.plot(finex,free_ground(finex))
nequil= 100
counts,edges,patches = plt.hist( x_arr[nequil:,:].flatten(),bins=40,normed=True)