# [ANN] State estimation with LowLevelParticleFilters.jl

LowLevelParticleFilters.jl is a library for state estimation, that is, given measurements y(t) from a dynamical system with inputs u(t), estimate the state vector x(t). Throughout, we assume discrete-time dynamics on the form

x(t+1) = f(x(t), u(t), p, t, w(t))\\ y(t) = g(x(t), u(t), p, t, e(t))

where p are some form of parameters, t is the time and w,e are disturbances (noise).
The documentation describes how to handle continuous-time ODEs on the form

\dot x(t) = f(x(t), u(t), p, t, w(t))

as well.

The library has existed for a while, but has never really been announced before. I just pushed it over to version 3.0, breaking the previous interface by moving to an interface similar to the SciML ecosystem where many functions accept a parameter vector p. The Documentation has also seen some improvements in the process.

We provide a number of filter types

• KalmanFilter. A standard Kalman filter. Is restricted to linear dynamics (possibly time varying) and Gaussian noise.

• ExtendedKalmanFilter: For nonlinear systems, the EKF runs a regular Kalman filter on linearized dynamics. Uses ForwardDiff.jl for linearization. The noise model must be Gaussian.

• UnscentedKalmanFilter: The Unscented Kalman filter often performs slightly better than the Extended Kalman filter but may be slightly more computationally expensive. The UKF handles nonlinear dynamics and measurement model, but still requires an additive Gaussian noise model and assumes all posterior distributions are Gaussian, i.e., can not handle multi-modal posteriors.

• ParticleFilter: The particle filter is a nonlinear estimator. This filter is simple to use and assumes that both dynamics noise and measurement noise are additive. Particle filters handle multi-modal posteriors.

• AuxiliaryParticleFilter: This filter is identical to ParticleFilter, but uses a slightly different proposal mechanism for new particles.

• AdvancedParticleFilter: This filter gives you more flexibility, at the expense of having to define a few more functions. This filter does not require the noise to be additive and is thus the most flexible filter type.

• DAEUnscentedKalmanFilter: An Unscented Kalman filter for differential-algebraic systems (DAE). Still somewhat experimental.

The code has been written to be reasonably fast and it supports StaticArrays everywhere. For simple systems, we can push about 7k particles per millisecond. We also support particle and Kalman smoothing as well as automatic differentiation through the filters using ForwardDiff.jl, making parameter estimation with the Prediction-Error Method (PEM) relatively easy. We also have a new example of estimating time-varying parameters in ODEs.

Happy filtering
Fredrik

26 Likes

Looks great, thanks for putting it together and writing such nice docs! I was just thinking about trying a DAE+state-space framework thing the other day.

1 Like

Nice work!

How hard would it be to call an external model compiled in C++. The model needs a file(s) that provides the current state, parameters and inputs. I am looking use this model for data assimilation.

Thanks!

As long as you can wrap the c++ model in a Julia function with the signature (x, u, p, t) - >x(t+1) you should be good to go. Wrapping C is generally not that hard, but if you need to go through a file, perhaps performance may suffer slightly.

1 Like

Thanks! I will see what I can do