rlabbe / Kalman-and-Bayesian-Filters-in-Python

Kalman Filter book using Jupyter Notebook. Focuses on building intuition and experience, not formal proofs. Includes Kalman filters,extended Kalman filters, unscented Kalman filters, particle filters, and more. All exercises include solutions.
Other
16.45k stars 4.16k forks source link

Terminology in gh filter function #144

Closed acerion closed 7 years ago

acerion commented 7 years ago

Hi!

I have two questions about terminology used in g_h_filter() function defined in chapter 1.5.1.

Question 1: In prediction step a following calculation is made: x_est = x + (dx*dt) Shouldn't the variable be called x_pred? From what I have read so far, adding (dxdt) to previous estimate resulted in a prediction. Later in definition of the function, the x_est is used to create estimate: `x = x_est + g residual` Maybe I'm just confused about terminology, but this is strongly supported by plot from cell 14: prediction (x_pred) equals previous estimate (x) plus predicted change (dxdt). We can then calculate new estimate (x) using prediction (x_pred + g residual). Additionally in function predict_using_gain_guess() defined in cell 15, in prediction step you named the variable as "prediction":

# predict new position
prediction = weight + gain_rate * time_step

Question 2: In the same function a following variable is defined: results = [] This variable will store estimates, and the result of gh filter is an array of estimates? I'm asking because from what I've read about Kalman filters so far, is that there is a confusion about the nature of the filter: that it should rather be considered as an estimator, not as a filter. So perhaps the question should be rather what is your position on "true nature" of Kalman filter: does it filter data from sensors, or does it estimate closest-to-reality values?

Best regards, Kamil

rlabbe commented 7 years ago

About 1, I think you are correct. It is a prediction, not an estimate. I've renamed the variables appropriately.

about 2, I broke a rule of programming - use meaningful names. 'results' is terrible! estimates is a far better name.

I'm somewhat uninterested in a philosophical debate about the meaning of 'filter'. Broadly speaking, all of these filters (there's that word!) do the following:

Optimal is in quotes: the KF is optimal for linear systems with white noise, a perfect physical model, and known noise covariances. That essentially never holds, but the math is simple, hence we use it.

And, it is never estimating "closest-to-reality" values - it is estimating closest to model values. If the model diverges from reality so will the filter. Make sense?

rlabbe commented 7 years ago

I just pushed a fix to the variable names.

acerion commented 6 years ago

Make sense?

Yes! Thank you or your answers, and for a great book!