simulate#

pypillometry.signal.gaussmarkov.simulate(model, n, fs=None, rng=None, return_states=False)[source]#

Simulate from a state-space model.

Parameters:
  • model (LGSSM or GaussMarkovModel) – a GaussMarkovModel is discretised at fs

  • n (int) – number of samples

  • fs (float, optional) – sampling rate in Hz (needed for a GaussMarkovModel)

  • rng (np.random.Generator or int, optional)

  • return_states (bool, optional) – also return the states

Return type:

ndarray | tuple[ndarray, ndarray]

Returns:

  • y ((n,) or (n, m) array) – observations ((n,) for a single channel)

  • x ((n, dim) array) – states (if return_states)

Examples

>>> from pypillometry.signal.gaussmarkov import OU, GaussMarkovModel
>>> y = simulate(GaussMarkovModel([OU(1., 50.)], noise=0.1), 1000, fs=1000, rng=0)
>>> y.shape
(1000,)