GaussMarkovModel#

class pypillometry.signal.gaussmarkov.GaussMarkovModel(components, noise=0.0, fixed=())[source]#

Bases: object

Gauss-Markov model: a sum of components plus white measurement noise.

The state is the stack of the component states (block-diagonal dynamics); the observation is the sum of the component outputs plus noise with standard deviation noise.

Parameters:
  • components (list of Component or dict of str to Component) – the components; a list gets names like "ou0", "matern1"

  • noise (float) – standard deviation of the measurement noise (the nugget is noise^2)

  • fixed (iterable of str, optional) – parameters held fixed when fitting (see fix())

Notes

Parameters are named "<component>.<param>" (e.g. "ou0.tau") and "noise". theta holds the log of the free parameters, the unconstrained vector used by the optimisers.

Examples

>>> model = GaussMarkovModel([OU(1., 50.), Matern(2., 500., nu=2.5)], noise=0.1)
>>> model.param_names
['ou0.sigma', 'ou0.tau', 'matern1.sigma', 'matern1.ell', 'noise']
>>> model.dim
4
>>> model.fix(["noise"]).free_names
['ou0.sigma', 'ou0.tau', 'matern1.sigma', 'matern1.ell']

Methods

cov

autocovariance of the observations at lags tau (ms), with noise

fix

Copy with parameters held fixed when fitting.

from_theta

copy with the free parameters set from their logs theta

psd

One-sided power spectral density of the observations at frequencies freq (Hz), in signal units squared per Hz, without the noise (white noise sampled at fs adds noise^2 / (fs / 2)).

to_lgssm

Discrete-time model for sampling rate fs (Hz).

unfix

copy with the parameters names free again

variogram

semivariogram of the observations at lags tau (ms), with nugget

with_params

copy with the parameters in dict params changed

Details

cov(tau)[source]#

autocovariance of the observations at lags tau (ms), with noise

Return type:

ndarray

fix(params)[source]#

Copy with parameters held fixed when fitting.

Parameters:

params (list of str or dict) – names, or a dict of names and the values to fix them at

Return type:

GaussMarkovModel

from_theta(theta)[source]#

copy with the free parameters set from their logs theta

Return type:

GaussMarkovModel

psd(freq)[source]#

One-sided power spectral density of the observations at frequencies freq (Hz), in signal units squared per Hz, without the noise (white noise sampled at fs adds noise^2 / (fs / 2)).

Return type:

ndarray

to_lgssm(fs)[source]#

Discrete-time model for sampling rate fs (Hz).

Parameters:

fs (float) – sampling rate in Hz

Return type:

LGSSM

unfix(names)[source]#

copy with the parameters names free again

Return type:

GaussMarkovModel

variogram(tau)[source]#

semivariogram of the observations at lags tau (ms), with nugget

Return type:

ndarray

with_params(params)[source]#

copy with the parameters in dict params changed

Return type:

GaussMarkovModel

property components: dict[str, Component]#

dict of name to component

property free_names: list[str]#

names of the parameters that are not fixed (the order of theta)

property n_diffuse: int#

number of components with a diffuse prior (Constant)

property params: dict[str, float]#

dict of all parameters, {"ou0.tau": ..., "noise": ...}

property slices: dict[str, slice]#

dict of name to the slice of the state that belongs to it

property theta: ndarray#

log of the free parameters