%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
n_person=2000
n_times=5000

t=np.arange(n_times)

steps=2*np.random.randint(0,2,(n_person,n_times))-1
amount=np.cumsum(steps,axis=1)

sd_amount=amount**2
mean_sd_amount=sd_amount.mean(axis=0)
plt.xlabel(r"$t$")
plt.ylabel(r"$\sqrt{\langle (\delta x)^2 \rangle}$")
plt.plot(t,np.sqrt(mean_sd_amount),'g*',t,np.sqrt(t),'r-')

1535548892645928989.png
1535548892645928989.png

看官大人,来点音乐?[player id='479320305,1697590,167691' autoplay='false'/]