From f248c4829e707e3b7379370c024c903123210404 Mon Sep 17 00:00:00 2001 From: Michael Clerx Date: Wed, 31 Oct 2018 19:00:43 +0000 Subject: [PATCH] Fix to noise generation for older numpy versions --- pints/noise.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pints/noise.py b/pints/noise.py index cbef0f0c4..fc0a8487e 100644 --- a/pints/noise.py +++ b/pints/noise.py @@ -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]