Documentation ¶
Overview ¶
Package kalman implements estimation for time series with non-uniform time steps. Implementations of the Kalman Filter and Kalman Smoother are provided, along with several built-in models for modelling common dynamic systems, such as the constant-velocity model and a Brownian model.
Index ¶
- type KalmanFilter
- func (kf *KalmanFilter) Covariance() mat.Matrix
- func (kf *KalmanFilter) Predict(t time.Time) error
- func (kf *KalmanFilter) SetCovariance(covariance mat.Matrix)
- func (kf *KalmanFilter) SetState(state mat.Vector)
- func (kf *KalmanFilter) State() mat.Vector
- func (kf *KalmanFilter) Time() time.Time
- func (kf *KalmanFilter) Update(t time.Time, m *models.Measurement) error
- type KalmanSmoother
- type MeasurementAtTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KalmanFilter ¶
type KalmanFilter struct {
// contains filtered or unexported fields
}
KalmanFilter is responsible for prediction and filtering of a given linear model. It is assumed that the process being modelled is a time series, and that the time steps are non-uniform and specified for each update and prediction operation.
func NewKalmanFilter ¶
func NewKalmanFilter(model models.LinearModel) *KalmanFilter
NewKalmanFilter returns a new KalmanFilter for the given linear model.
func (*KalmanFilter) Covariance ¶
func (kf *KalmanFilter) Covariance() mat.Matrix
Covariance returns the current covaraince of the model.
func (*KalmanFilter) Predict ¶
func (kf *KalmanFilter) Predict(t time.Time) error
Predict advances the KalmanFilter from the internal current time to the given time using the built-in linear model. The state of the filter is updated and the current time is updated. Each time can be no earlier than the current time of the filter.
func (*KalmanFilter) SetCovariance ¶
func (kf *KalmanFilter) SetCovariance(covariance mat.Matrix)
SetCovariance resets the covariance of the Kalman Filter to the given value.
func (*KalmanFilter) SetState ¶
func (kf *KalmanFilter) SetState(state mat.Vector)
SetState resets the state of the Kalman Filter to the given value.
func (*KalmanFilter) State ¶
func (kf *KalmanFilter) State() mat.Vector
State returns the current hidden state of the KalmanFilter. Example models provided with this package often provide functions to extract meaningful information from the state vector, such as .Velocity() for the provided constant velocity model.
func (*KalmanFilter) Time ¶
func (kf *KalmanFilter) Time() time.Time
Time returns the time for which the current hidden state is an estimate. The time is monotone increasing.
func (*KalmanFilter) Update ¶
func (kf *KalmanFilter) Update(t time.Time, m *models.Measurement) error
Update is used to take a new measurement from a sensor and fuse it to the model. The time field must be no earlier than the current time of the filter.
type KalmanSmoother ¶
type KalmanSmoother struct {
// contains filtered or unexported fields
}
KalmanSmoother implements Rauch–Tung–Striebel smoothing.
func NewKalmanSmoother ¶
func NewKalmanSmoother(model models.LinearModel) *KalmanSmoother
NewKalmanSmoother creates a new smoother for the given model.
func (*KalmanSmoother) Smooth ¶
func (kf *KalmanSmoother) Smooth(measurements ...*MeasurementAtTime) ([]models.State, error)
Smooth computes optimal estimates of the model states by using all measurements. This is done by running a regular Kalman Filter and then performing a backwards pass using the Rauch–Tung–Striebel algorithm. Better results can be achieved since each state is estimated based on the entire history of the process, including the future and past observations.
type MeasurementAtTime ¶
type MeasurementAtTime struct { models.Measurement Time time.Time }
MeasurementAtTime represents a measurement taken at a given time.
func NewMeasurementAtTime ¶
func NewMeasurementAtTime(t time.Time, m *models.Measurement) *MeasurementAtTime
NewMeasurementAtTime is a helper for initializing measurement at time structs.