rlabbe / filterpy

Python Kalman filtering and optimal estimation library. Implements Kalman filter, particle filter, Extended Kalman filter, Unscented Kalman filter, g-h (alpha-beta), least squares, H Infinity, smoothers, and more. Has companion book 'Kalman and Bayesian Filters in Python'.
MIT License
3.31k stars 617 forks source link

change comparison to <= to avoid index error due to roundoff error #186

Closed ernstklrb closed 5 years ago

ernstklrb commented 5 years ago

The last element of 'position' can become equal to 1.0 due to roundoff error, in case the random number drawn is very close to 1. In this case, the index into 'cumulative_sum' will exceed N (before this commit).