Skip to content

Commit

Permalink
Fix to noise generation for older numpy versions
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelClerx committed Oct 31, 2018
1 parent 6fb51de commit f248c48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pints/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def ar1(rho, sigma, n):
return np.array([])

# Generate noise
v = np.random.normal(0, sigma * np.sqrt(1 - rho**2), n)
s = sigma * np.sqrt(1 - rho**2)
if s == 0:
v = np.zeros(n)
else:
v = np.random.normal(0, s, n)
v[0] = np.random.rand()
for t in range(1, n):
v[t] += rho * v[t - 1]
Expand Down

0 comments on commit f248c48

Please sign in to comment.