Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tbegin = 0 #Time beginst at
- tend = 1 #Time stops at
- t = tend - tbegin
- N = 10000 #Numbert of steps
- dt = float(t)/N
- t_arr = np.linspace(0, 1, N) #All the time steps
- y = np.zeros(N)
- y[0] = 0.3 #Starting point
- if(len(t_arr) == N): #Just to check that these are equal
- print "OK"
- W = np.zeros(N)
- for i in range(0, N - 1): #Get the steps for the Wiender process so that we can calculate dW = W[t+1] - W[t]
- W[i+1] = W[i] + np.sqrt(dt) * np.random.normal(0, 1)
- for i in range(1, N):
- y[i] = y[i-1] + v * y[i-1] * dt + np.sqrt(2 * D * y[i-1]) * (W[i] - W[i-1])
- plt.plot(t_arr, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement