kalman_filter#

pypillometry.signal.gaussmarkov.kalman_filter(model, y, mask=None, obs_var=None, n_diffuse=0, segments=None)[source]#

Run the Kalman filter and keep everything.

Parameters:
  • model (LGSSM)

  • y (array, (T,) or (T, m)) – observations; NaN, inf and masked values are missing

  • mask (array of bool, optional) – True for additional missing samples

  • obs_var (array, (T,) or (T, m), optional) – noise variance of each sample, instead of the diagonal of R

  • n_diffuse (int or sequence of int, optional) – number of valid observations (of each channel) at the start of each segment that are left out of the likelihood, because they only determine states with a diffuse prior (a very large variance in P0); default 0

  • segments (list of (start, stop), optional) – sample indices of independent segments: the state restarts from (m0, P0) at each start; samples outside the segments are missing. Default: the whole signal is one segment.

Return type:

FilterResult

Notes

Stores O(T n^2) numbers; use kalman_loglik() when only the likelihood is needed. With obs_var, n_diffuse or segments, the channels are processed one after the other (they need a diagonal R): the innovation of a channel and its variance are then conditional on the channels before it at the same sample, and innov_var is diagonal.