Last active
September 16, 2019 15:04
-
-
Save achutharanga/4e542c39bcbd28071d4f to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* {@link Kalman} is an one dimensional implementation of KALMAN filter used to | |
* predict a noisy signal containing fluctuations due to measurement errors, noise etc. | |
* | |
* @author AchuthaRanga.Chenna | |
* | |
*/ | |
public class SimpleKalman { | |
/** process noise COVARIANCE */ | |
private double q = 1.48d; | |
/** measurement noise COVARIANCE */ | |
private double r = 442.0d; | |
/** Measurement value */ | |
private double x = 0d; | |
/** estimation error COVARIANCE */ | |
private double p = 50d; | |
/** KALMAN gain */ | |
private double k = 1d; | |
/** | |
* Init the filter with initial value of signal. | |
* @param initial_measurement | |
*/ | |
public Kalman(double initial_measurement) { | |
this.x = initial_measurement; | |
} | |
/** | |
* Method to get the predicted value of the measured signal value. | |
* | |
* @param measurement | |
* value from real time data. | |
* @return predicted measurement. | |
*/ | |
public double getPredicted_Value(double measurement) { | |
p = p + q; | |
k = p / (p + r); | |
x = x + k * (measurement - x); | |
p = (1 - k) * p; | |
return x; | |
} | |
} |
what's p? where's 50 come from? and what's measurement? is it different with x?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
q, r has to be adjusted according to the usage