Noise
¶
A collection of noise related classes and functions.
Specific noises inherit from the abstract class Noise
- class tvb.simulator.noise.Noise(**kwargs)[source]¶
Traited class [tvb.simulator.noise.Noise]¶
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.
- __init__(**kwargs)[source]¶
The default init accepts kwargs for all declarative attrs and sets them to the given values
- coloured(shape)[source]¶
Generate colored noise. [FoxVemuri_1988]
Attributes declared¶
- ntautvb.simulator.noise.Noise.ntau = Float(field_type=<class ‘float’>, default=0.0, required=True)
The noise correlation time
- noise_seedtvb.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_streamtvb.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_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}\]
- coloured(shape)[source]¶
Generate colored noise. [FoxVemuri_1988]
- class tvb.simulator.noise.Additive(**kwargs)[source]¶
Traited class [tvb.simulator.noise.Additive]¶
Additive noise which, assuming the source noise is Gaussian with unit variance, will result in noise with a standard deviation of nsig.
Attributes declared¶
- nsigtvb.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.
- ntautvb.simulator.noise.Noise.ntau = Float(field_type=<class ‘float’>, default=0.0, required=True)
The noise correlation time
- noise_seedtvb.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_streamtvb.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 float64. 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.
- class tvb.simulator.noise.Multiplicative(**kwargs)[source]¶
Traited class [tvb.simulator.noise.Multiplicative]¶
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.
Attributes declared¶
- nsigtvb.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.
- btvb.simulator.noise.Multiplicative.b = Attr(field_type=<class ‘tvb.datatypes.equations.TemporalApplicableEquation’>, default=<tvb.datatypes.equations.Linear object at 0x7f78c87c8cd0>, required=True)
A function evaluated on the state-variables, the result of which enters as the diffusion coefficient.
- ntautvb.simulator.noise.Noise.ntau = Float(field_type=<class ‘float’>, default=0.0, required=True)
The noise correlation time
- noise_seedtvb.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_streamtvb.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 float64. 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.