Package dev.nm.stat.dlm.univariate
Class LinearKalmanFilter
- java.lang.Object
-
- dev.nm.stat.dlm.univariate.LinearKalmanFilter
-
public class LinearKalmanFilter extends Object
The Kalman filter, also known as linear quadratic estimation (LQE), is an algorithm which uses a series of measurements observed over time, containing noise (random variations) and other inaccuracies, and produces estimates of unknown variables that tend to be more precise than those that would be based on a single measurement alone. More formally, the Kalman filter operates recursively on streams of noisy input data to produce a statistically optimal estimate of the underlying system state.
-
-
Constructor Summary
Constructors Constructor Description LinearKalmanFilter(DLM model)
Construct a Kalman filter from a univariate controlled dynamic linear model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
filtering(double[] Y)
Filter the observations without control variable.void
filtering(double[] Y, double[] U)
Filter the observations.double
getFittedState(int t)
Get the posterior expected state.double[]
getFittedStates()
Get the posterior expected states.double
getFittedStateVariance(int t)
Get the posterior expected state variance.double
getKalmanGain(int t)
Get the Kalman gain.double
getPredictedObservation(int t)
Get the prior observation prediction.double[]
getPredictedObservations()
Get the prior observation predictions.double
getPredictedObservationVariance(int t)
Get the prior observation prediction variance.double
getPredictedState(int t)
Get the prior expected state.double[]
getPredictedStates()
Get the prior expected states.double
getPredictedStateVariance(int t)
Get the prior expected state variance.int
size()
Get T, the number of hidden states or observations.
-
-
-
Constructor Detail
-
LinearKalmanFilter
public LinearKalmanFilter(DLM model)
Construct a Kalman filter from a univariate controlled dynamic linear model.- Parameters:
model
- a univariate controlled DLM
-
-
Method Detail
-
filtering
public void filtering(double[] Y, double[] U)
Filter the observations.- Parameters:
Y
- the observationsU
- the controls
-
filtering
public void filtering(double[] Y)
Filter the observations without control variable.- Parameters:
Y
- the observations
-
size
public int size()
Get T, the number of hidden states or observations.- Returns:
- T
-
getFittedStates
public double[] getFittedStates()
Get the posterior expected states.- Returns:
- the fitted states
-
getPredictedStates
public double[] getPredictedStates()
Get the prior expected states.- Returns:
- the predicted states
-
getPredictedObservations
public double[] getPredictedObservations()
Get the prior observation predictions.- Returns:
- the predicted observations
-
getFittedState
public double getFittedState(int t)
Get the posterior expected state.- Parameters:
t
- time, t ≥ 1- Returns:
- the fitted state
-
getFittedStateVariance
public double getFittedStateVariance(int t)
Get the posterior expected state variance.- Parameters:
t
- time, t ≥ 1- Returns:
- the fitted state variance
-
getPredictedState
public double getPredictedState(int t)
Get the prior expected state.- Parameters:
t
- time, t ≥ 1- Returns:
- the predicted state
-
getPredictedStateVariance
public double getPredictedStateVariance(int t)
Get the prior expected state variance.- Parameters:
t
- time, t ≥ 1- Returns:
- the predicted state variance
-
getPredictedObservation
public double getPredictedObservation(int t)
Get the prior observation prediction.- Parameters:
t
- time, t ≥ 1- Returns:
- the predicted observation
-
getPredictedObservationVariance
public double getPredictedObservationVariance(int t)
Get the prior observation prediction variance.- Parameters:
t
- time, t ≥ 1- Returns:
- the predicted observation variance
-
getKalmanGain
public double getKalmanGain(int t)
Get the Kalman gain.- Parameters:
t
- time, t ≥ 1- Returns:
- the Kalman gain
-
-