baggepinnen / LowLevelParticleFilters.jl

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

Does `correct!()` support `missing` samples as explained in docs? #136

Closed justidy1 closed 8 months ago

justidy1 commented 8 months ago

Hi, this issue pertains to a prior issue and this section of the docs

I was digging through the code to understand whether correct!() could be modified to bypass updating the weights of particles in the case that the observation y[i] == missing, i.e. regular sampling rate but with sparse dropout of measurements. Based on the prior issue I was led to believe that this it is not the case that correct!() knows about missing data and one would have to write a manual loop to handle this case (as the documentation suggests).

However, the correct!() function calls measurement_equation!() which has a short circuit evaluation any(ismissing.(y)) && return w

To me, this looks like it would mean that functions such as correct!() does know to "ignore" missing observations, and therefore higher-level loops like forward_trajectorry() indeed handle missing data already. If how I am understanding it is truly what's going on, then could the documentation be updated to reflect this (i.e. the loops used by forward_trajectorry() and the like do not apply corrections if the observation for that time step is missing)? Else, I'd like to know whether the interpretation of the short circuit should be.

Thanks!

baggepinnen commented 8 months ago

We do not support missing values for all filters at this point. The docs do not intend to claim that we support missing values, if that's your interpretation of the "Dropped samples" section it needs some clarification :) The docs are simply trying to say that supporting missing values in your own filter loop is trivial.

justidy1 commented 8 months ago

Thank you! That make sense, I was just a bit confused.

Just one more quick question for clarification. How do you interpret the short circuit evaluation mentioned above?

baggepinnen commented 8 months ago

How do you interpret the short circuit evaluation mentioned above?

As you say, it's there to handle missing measurements. The problem is that not all filters have this mechanism implemented yet. The method used there is also not always the optimal way to handle missing measurements. In cases when you have more than one sensor, you can still perform the measurement update with a subset of the measurements if some but not all are missing.

justidy1 commented 8 months ago

Okay, thank you for the clarification!