Integrators

Monitors

# Noise¶

A collection of noise related classes and functions.

Specific noises inherit from the abstract class Noise

class tvb.simulator.noise.Noise(**kwargs)[source]

Defines a base class for noise. Specific noises are derived from this class for use in stochastic integrations.

 [KloedenPlaten_1995] (1, 2, 3) Kloeden and Platen, Springer 1995, Numerical solution of stochastic differential equations.
 [ManellaPalleschi_1989] Manella, R. and Palleschi V., Fast and precise algorithm for computer simulation of stochastic differential equations, Physical Review A, Vol. 40, Number 6, 1989. [3381-3385]
 [Mannella_2002] Mannella, R., Integration of Stochastic Differential Equations on a Computer, Int J. of Modern Physics C 13(9): 1177–1194, 2002.
 [FoxVemuri_1988] (1, 2, 3) Fox, R., Gatland, I., Rot, R. and Vemuri, G., * Fast , accurate algorithm for simulation of exponentially correlated colored noise*, Physical Review A, Vol. 38, Number 11, 1988. [5938-5940]
__init__(**kwargs)[source]
configure_white(dt, shape=None)[source]

Set the time step (dt) of noise or integration time

generate(shape, lo=-1.0, hi=1.0)[source]

Generate noise realization.

white(shape)[source]

Generate white noise.

coloured(shape)[source]

Generate colored noise. [FoxVemuri_1988]

ntau : tvb.simulator.noise.Noise.ntau = Float(field_type=<class ‘float’>, default=0.0, required=True)
The noise correlation time
noise_seed : tvb.simulator.noise.Noise.noise_seed = Int(field_type=<class ‘int’>, default=42, required=True)
A random seed used to initialise the random_stream if it is missing.
random_stream : tvb.simulator.noise.Noise.random_stream = Attr(field_type=<class ‘numpy.random.mtrand.RandomState’>, default=None, required=False)
An instance of numpy’s RandomState associated with thisspecific Noise object. Used when you need to resume a simulation from a state saved to disk

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

ntau

Declares a float. This is different from Attr(field_type=float). The former enforces float subtypes. This allows any type that can be safely cast to the declared float type according to numpy rules.

Reading and writing this attribute is slower than a plain python attribute. In performance sensitive code you might want to use plain python attributes or even better local variables.

noise_seed

Declares an integer This is different from Attr(field_type=int). The former enforces int subtypes This allows all integer types, including numpy ones that can be safely cast to the declared type according to numpy rules

random_stream

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

configure()[source]

Run base classes configure to setup traited attributes, then ensure that the random_stream attribute is properly configured.

configure_white(dt, shape=None)[source]

Set the time step (dt) of noise or integration time

configure_coloured(dt, shape)[source]

One of the simplest forms for coloured noise is exponentially correlated Gaussian noise [KloedenPlaten_1995].

We give the initial conditions for coloured noise using the integral algorith for simulating exponentially correlated noise proposed by [FoxVemuri_1988]

To start the simulation, an initial value for $$\eta$$ is needed. It is obtained in accord with Eqs.[13-15]:

$\begin{split}m &= \text{random number}\\ n &= \text{random number}\\ \eta &= \sqrt{-2D\lambda\ln(m)}\,\cos(2\pi\,n)\end{split}$

where $$D$$ is standard deviation of the noise amplitude and $$\lambda = \frac{1}{\tau_n}$$ is the inverse of the noise correlation time. Then we set $$E = \exp{-\lambda\,\delta\,t}$$ where $$\delta\,t$$ is the integration time step.

After that the exponentially correlated, coloured noise, is obtained:

$\begin{split}a &= \text{random number}\\ b &= \text{random number}\\ h &= \sqrt{-2D\lambda\,(1 - E^2)\,\ln{a}}\,\cos(2\pi\,b)\\ \eta_{t+\delta\,t} &= \eta_{t}E + h\end{split}$
generate(shape, lo=-1.0, hi=1.0)[source]

Generate noise realization.

coloured(shape)[source]

Generate colored noise. [FoxVemuri_1988]

white(shape)[source]

Generate white noise.

gfun(state_variables)[source]
Additive noise which, assuming the source noise is Gaussian with unit variance, will result in noise with a standard deviation of nsig.
nsig : tvb.simulator.noise.Additive.nsig = NArray(label=’$$D$$‘, dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
The noise dispersion, it is the standard deviation of the distribution from which the Gaussian random variates are drawn. NOTE: Sensible values are typically ~<< 1% of the dynamic range of a Model’s state variables.
ntau : tvb.simulator.noise.Noise.ntau = Float(field_type=<class ‘float’>, default=0.0, required=True)
The noise correlation time
noise_seed : tvb.simulator.noise.Noise.noise_seed = Int(field_type=<class ‘int’>, default=42, required=True)
A random seed used to initialise the random_stream if it is missing.
random_stream : tvb.simulator.noise.Noise.random_stream = Attr(field_type=<class ‘numpy.random.mtrand.RandomState’>, default=None, required=False)
An instance of numpy’s RandomState associated with thisspecific Noise object. Used when you need to resume a simulation from a state saved to disk

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

nsig

Declares a numpy array. dtype enforces the dtype. The default dtype is float32. An optional symbolic shape can be given, as a tuple of Dim attributes from the owning class. The shape will be enforced, but no broadcasting will be done. domain declares what values are allowed in this array. It can be any object that can be checked for membership Defaults are checked if they are in the declared domain. For performance reasons this does not happen on every attribute set.

gfun(state_variables)[source]

Linear additive noise, thus it ignores the state_variables.

$g(x) = \sqrt{2D}$
class tvb.simulator.noise.Multiplicative(**kwargs)[source]

With “external” fluctuations the intensity of the noise often depends on the state of the system. This results in the (general) stochastic differential formulation:

$dX_t = a(X_t)\,dt + b(X_t)\,dW_t$

for appropriate coefficients $$a(x)$$ and $$b(x)$$, which might be constants.

From [KloedenPlaten_1995], Equation 1.9, page 104.

nsig : tvb.simulator.noise.Multiplicative.nsig = NArray(label=’$$D$$‘, dtype=float64, default=array([1.]), dim_names=(), ndim=None, required=True)
The noise dispersion, it is the standard deviation of the distribution from which the Gaussian random variates are drawn. NOTE: Sensible values are typically ~<< 1% of the dynamic range of a Model’s state variables.
b : tvb.simulator.noise.Multiplicative.b = Attr(field_type=<class ‘tvb.datatypes.equations.TemporalApplicableEquation’>, default=<tvb.datatypes.equations.Linear object at 0x7f71b3e5c3d0>, required=True)
A function evaluated on the state-variables, the result of which enters as the diffusion coefficient.
ntau : tvb.simulator.noise.Noise.ntau = Float(field_type=<class ‘float’>, default=0.0, required=True)
The noise correlation time
noise_seed : tvb.simulator.noise.Noise.noise_seed = Int(field_type=<class ‘int’>, default=42, required=True)
A random seed used to initialise the random_stream if it is missing.
random_stream : tvb.simulator.noise.Noise.random_stream = Attr(field_type=<class ‘numpy.random.mtrand.RandomState’>, default=None, required=False)
An instance of numpy’s RandomState associated with thisspecific Noise object. Used when you need to resume a simulation from a state saved to disk

gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)

nsig

Declares a numpy array. dtype enforces the dtype. The default dtype is float32. An optional symbolic shape can be given, as a tuple of Dim attributes from the owning class. The shape will be enforced, but no broadcasting will be done. domain declares what values are allowed in this array. It can be any object that can be checked for membership Defaults are checked if they are in the declared domain. For performance reasons this does not happen on every attribute set.

b

An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.

gfun(state_variables)[source]

Scale the noise by the noise dispersion and the diffusion coefficient. By default, the diffusion coefficient $$b$$ is a constant. It reduces to the simplest scheme of a linear SDE with Multiplicative Noise: homogeneous constant coefficients. See [KloedenPlaten_1995], Equation 4.6, page 119.