feat: add KalmanFilter, a scalar Kalman filter with sensor fusion - #7592
Open
alxkm wants to merge 1 commit into
Open
feat: add KalmanFilter, a scalar Kalman filter with sensor fusion#7592alxkm wants to merge 1 commit into
alxkm wants to merge 1 commit into
Conversation
Co-authored-by: Oleksandr Klymenko <19151554+alxkm@users.noreply.github.com> Signed-off-by: alxkm <19151554+alxkm@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7592 +/- ##
============================================
+ Coverage 80.74% 80.79% +0.04%
- Complexity 7570 7598 +28
============================================
Files 818 819 +1
Lines 24257 24320 +63
Branches 4772 4775 +3
============================================
+ Hits 19587 19650 +63
- Misses 3906 3907 +1
+ Partials 764 763 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a scalar (one-dimensional) Kalman filter under
com.thealgorithms.streaming, the standard entry point to recursive Bayesian state estimation. The repository has no Kalman filter yet.The filter tracks a quantity that drifts while every measurement of it is noisy:
The gain
kis the share of the measurement that gets believed; the variances tune it, not the caller. Callingupdateonce per sensor, each with its own noise, is sensor fusion, andfuse(double[], double[])gives the same thing in closed form. Both steps are O(1) in time and memory. (The covariance update is coded asp * r / (p + r)rather than(1 - k) * p; the two are algebraically equal, but the latter loses most of its significant digits when the gain is near one, as it is on the first measurements.)KalmanFilterTestcovers 17 cases. Two of them check the implementation against independent ground truth: with a diffuse prior and no process noise the filter must reduce to the running mean, and per-sensor updates must equal the closed-form inverse-variance fusion. The rest cover argument validation, covariance growth and shrinkage, control input, noise reduction on a constant signal, tracking a ramp, andreset.Checklist
clang-format -i --style=file path/to/your/file.java