probml / dynamax

State Space Models library in JAX
https://probml.github.io/dynamax/
MIT License
634 stars 70 forks source link

Robust lgssm posterior sample #321

Closed calebweinreb closed 1 year ago

calebweinreb commented 1 year ago

This PR modifies lgssm_posterior_sample to avoid NaNs caused by numerical instability, as described in issue https://github.com/probml/dynamax/issues/320.

Specifically, the new version of lgssm_posterior_sample now pads the diagonal of the covariance matrix before passing it to the MVN sampler. The amount of padding is controlled by an optional jitter parameter that is set to 0 by default. The code runs identically unless a user specifies a nonzero value for the jitter.

Note that this PR builds on top of https://github.com/probml/dynamax/pull/319 and should be merged second.