Noise generators¶
- Pints contains a module
pints.noise
that contains methods that generate - different kinds of noise.
- This can then be added to simulation output to create “realistic” experimental
data.
Overview:
-
pints.noise.
ar1
(rho, sigma, n)[source]¶ Generates first-order autoregressive (AR1) noise that can be added to a vector of simulated data.
The generated noise follows the distribution
\[e(t) = \rho e(t - 1) + v(t),\]where \(v(t) \stackrel{\text{iid}}{\sim }\mathcal{N}(0, \sigma \sqrt{1 - \rho ^2})\).
Returns an array of length
n
containing the generated noise.Parameters: - rho – Determines the magnitude of the noise \(\rho\) (see above). Must be less than 1.
- sigma – The marginal standard deviation \(\sigma\) of
e(t)
(see above). Must be greater than zero. - n – The length of the signal. (Only single time-series are supported.)
Example
values = model.simulate(parameters, times) noisy_values = values + noise.ar1(0.9, 5, len(values))
-
pints.noise.
ar1_unity
(rho, sigma, n)[source]¶ Generates noise following an autoregressive order 1 process of mean 1, that a vector of simulated data can be multiplied with.
Returns an array of length
n
containing the generated noise.Parameters: - rho – Determines the magnitude of the noise (see
ar1()
). Must be less than or equal to 1. - sigma – The marginal standard deviation of
e(t)
(seear()
). Must be greater than 0. - n (int) – The length of the signal. (Only single time-series are supported.)
Example
values = model.simulate(parameters, times) noisy_values = values * noise.ar1_unity(0.5, 0.8, len(values))
- rho – Determines the magnitude of the noise (see
-
pints.noise.
arma11
(rho, theta, sigma, n)[source]¶ Generates an ARMA(1,1) error process of the form:
\[e(t) = (1 - \rho) + \rho * e(t - 1) + v(t) + \theta * v(t-1),\]where \(v(t) \stackrel{\text{iid}}{\sim }\mathcal{N}(0, \sigma ')\), and
\[\sigma ' = \sigma \sqrt{\frac{1 - \rho ^ 2}{1 + 2 \theta \rho + \theta ^ 2}}.\]
-
pints.noise.
arma11_unity
(rho, theta, sigma, n)[source]¶ Generates an ARMA(1,1) error process of the form:
e(t) = (1 - rho) + rho * e(t - 1) + v(t) + theta * v[t-1]
,where
v(t) ~ iid N(0, sigma')
,and
sigma' = sigma * sqrt((1 - rho^2) / (1 + 2 * theta * rho + theta^2))
.Returns an array of length
n
containing the generated noise.Parameters: - rho – Determines the long-run persistence of the noise (see
ar1()
). Must be less than 1. - theta – Contributes to first order autocorrelation of noise. Must be less than 1.
- sigma – The marginal standard deviation of
e(t)
(seear()
). Must be greater than 0. - n (int) – The length of the signal. (Only single time-series are supported.)
Example
values = model.simulate(parameters, times) noisy_values = values * noise.ar1_unity(0.5, 0.8, len(values))
- rho – Determines the long-run persistence of the noise (see
-
pints.noise.
independent
(sigma, shape)[source]¶ Generates independent Gaussian noise iid \(\mathcal{N}(0,\sigma)\).
Returns an array of shape
shape
containing the generated noise.Parameters: - sigma – The standard deviation of the noise. Must be zero or greater.
- shape – A tuple (or sequence) defining the shape of the generated noise array.
Example
values = model.simulate(parameters, times) noisy_values = values + noise.independent(5, values.shape)
-
pints.noise.
multiplicative_gaussian
(eta, sigma, f)[source]¶ Generates multiplicative Gaussian noise for a single output.
With multiplicative noise, the measurement error scales with the magnitude of the output. Given a model taking the form,
\[X(t) = f(t; \theta) + \epsilon(t)\]multiplicative Gaussian noise models the noise term as:
\[\epsilon(t) = f(t; \theta)^\eta v(t)\]where v(t) is iid Gaussian:
\[v(t) \stackrel{\text{ iid }}{\sim} \mathcal{N}(0, \sigma)\]The output magnitudes
f
are required as an input to this function. The noise terms are returned in an array of the same shape asf
.Parameters: - eta – The exponential power controlling the rate at which the noise scales with the output. The argument must be either a float (for single-output or multi-output noise) or an array_like of floats (for multi-output noise only, with one value for each output).
- sigma – The baseline standard deviation of the noise (must be greater than zero). The argument must be either a float (for single-output or multi-output noise) or an array_like of floats (for multi-output noise only, with one value for each output).
- f – A NumPy array giving the time-series for the output over time. For
multiple outputs, the array should have shape
(n_outputs, n_times)
.