I am trying to solve some stochastic differential equations, with Gaussian noise. I wonder if is better to use a Noise Vector:
eta = np.random.normal(size=N)*sqrtdt
q = []
p = []
q.append(1.0)
p.append(1.0)
for i in range(N):
q.append(f(q[i],p[i],eta[i])
p.append(g(q[i],p[i],eta[i])
with f and g well behaved functions, or if I should create the random number in each iteration:
q = []
p = []
q.append(1.0)
p.append(1.0)
for i in range(N):
eta = np.random.normal()*sqrtdt
q.append(f(q[i],p[i],eta)
p.append(g(q[i],p[i],eta)
This code should be put into another for loop and run for several values of N, which varies from 10^4 to 10^9. I am also open to another way to write this, I know for loops are not the closest to Python mindset.
Aucun commentaire:
Enregistrer un commentaire