baggepinnen / LowLevelParticleFilters.jl

State estimation, smoothing and parameter estimation using Kalman and particle filters.
https://baggepinnen.github.io/LowLevelParticleFilters.jl/stable
Other
114 stars 15 forks source link

Particle filter with second order Markov model #133

Closed danscr closed 7 months ago

danscr commented 7 months ago

Is it possible to model the dynamics of a particle filter as $$x_t = a1 x{t-1} + a2 x{t-2} + noise,$$ where $a_i$ are weighting factors fulfilling $\sum ai = 1$? I assume it should be possible to have the state be a vector $[x{t-1}, x_{t-2}]$, but this creates quite some redundancy. Is there a way to access the previous state from within the dynamics function?

baggepinnen commented 7 months ago

Having $[x{t-1}, x{t-2}]$ be the state vector is indeed the way to go. This does not introduce much redundancy other than in memory, the full dimension of the state is indeed given by 2 times the dimension of $x$, and this is what determine the statistical properties regarding how densely the state space is sampled etc.

There is no way to access state older than the last step, the definition of state is the complete set of information that is required to predict the future, hence, $x_t$ is technically not a valid state representation in the system $$x_t = a1 x{t-1} + a2 x{t-2} + noise,$$

One could implement a custom particle filter to handle this case if the use of memory becomes a bottleneck, but his would have to special case not only the dynamics update, but also handling of the initial state etc. since you'd need multiple past values of $x$ to initialize the filter.

A further complication would be in the resampling step, since it would not be enough to resample the current value of $x$, you'd have to also copy over the history of $x$ in the resampling step.

BTW, this model is linear, is the noise Gaussian? If so, I'd use a Kalman filter instead

danscr commented 7 months ago

Thanks for the explanation! I'll then proceed as you suggested. The noise in my current dynamics is not always Gaussian, since I have some parameters constrained to certain intervals. But later on I might simplify my model to be able to use Kalman filter.

baggepinnen commented 7 months ago

Cool, I'll close this issue for now, feel free to continue the discussion if you have further questions :)