Title: | 'RcppArmadillo'-Based Kalman Filtering |
---|---|
Description: | An 'RcppArmadillo'-based port of the Kalman filtering code in the 'EKF/UKF Toolbox for Matlab' by Simo Särkkä, Jouni Hartikainen, and Arno Solin is provided. Note that this package is at this point still incomplete, but contains two demo functions replicating demos in 'EKF/UKF'. |
Authors: | Dirk Eddelbuettel |
Maintainer: | Dirk Eddelbuettel <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.6.1 |
Built: | 2024-10-10 04:28:50 UTC |
Source: | https://github.com/eddelbuettel/rcppkalman |
This package provides R with a C++ port of some functions from the EKF/UKF Toolbox for Matlab by Simo Särkkä, Jouni Hartikainen, and Arno Solin.
TBD
The EKF/UKF Toolbox for Matlab was written by Simo Särkkä, Jouni Hartikainen, and Arno Solin. Dirk Eddelbuettel wrote this package, and maintains it.
See http://becs.aalto.fi/en/research/bayes/ekfukf/ for the EKF/UKF Toolbox.
This function computes the exponential of a matrix.
expm(x)
expm(x)
x |
An numeric matrix |
This functions calls the expm
function from the eponymous package
expm. This is implemented via a registered function call, and does
not required explicit linking at the C level. However, the expm package
is imported in order to access its registered function at the C level.
As the documentation of package expm states, the underlying implementation borrows from the Matrix package which itself takes it from GNU Octave.
A numeric matrix
Dirk Eddelbuettel
The expm package and its documentation.
## example is from the vignette in package expm M <- matrix(c(4, 1, 1, 2, 4, 1, 0, 1, 4), 3, 3) ## expected output expM <- matrix(c(147.8666, 127.7811, 127.7811, 183.7651, 183.7651, 163.6796, 71.79703, 91.88257, 111.96811), 3, 3) ## we only have the expected result to about six digits all.equal(expm(M), expM, tolerance=1.0e-6)
## example is from the vignette in package expm M <- matrix(c(4, 1, 1, 2, 4, 1, 0, 1, 4), 3, 3) ## expected output expM <- matrix(c(147.8666, 127.7811, 127.7811, 183.7651, 183.7651, 163.6796, 71.79703, 91.88257, 111.96811), 3, 3) ## we only have the expected result to about six digits all.equal(expm(M), expM, tolerance=1.0e-6)
This function performs the Kalman Filter prediction step
kfPredict(x, P, A, Q, B, u)
kfPredict(x, P, A, Q, B, u)
x |
An N x 1 mean state estimate of previous step |
P |
An N x N state covariance of previous step |
A |
(Optional, default idendity) transition matrix of the discrete model |
Q |
(Optional, default zero) process noise of discrete model |
B |
(Optional, default idendity) input effect matrix |
u |
(Optional, default empty) constant input |
A list with two elements
the predicted state mean, and
the predicted state covariance.
The EKF/UKF Toolbox was written by Simo Särkkä, Jouni Hartikainen, and Arno Solin.
Dirk Eddelbuettel is porting this package to R and C++, and maintaing it.
kfUpdate, ltiDisc and the documentation for the EKF/UKF toolbox at http://becs.aalto.fi/en/research/bayes/ekfukf
This function performs the Kalman Filter measurement update step
kfUpdate(x, P, y, H, R)
kfUpdate(x, P, y, H, R)
x |
An N x 1 mean state estimate after prediction step |
P |
An N x N state covariance after prediction step |
y |
A D x 1 measurement vector. |
H |
Measurement matrix. |
R |
Measurement noise covariance. |
This functions performs the Kalman Filter measurement update step.
A list with elements
the update state mean,
the update state covariance,
the computed Kalman gain,
the mean of the predictive distribution of Y, and
the covariance of the predictive distribution of Y
The EKF/UKF Toolbox was written by Simo Särkkä, Jouni Hartikainen, and Arno Solin.
Dirk Eddelbuettel is porting this package to R and C++, and maintaing it.
kfPredict and the documentation for the EKF/UKF toolbox at http://becs.aalto.fi/en/research/bayes/ekfukf
Discretize Linear Time-Invariant ODE with Gaussian Noise
ltiDisc(F, L, Q, dt)
ltiDisc(F, L, Q, dt)
F |
An N x N feedback matrix |
L |
(Optional, default idendity) N x L noise effect matrix |
Q |
(Optionalm default zeros) L x L diagonal spectral density |
dt |
(Option, default one) time step |
This function discretizes the linear time-invariant (LTI) ordinary differential equation (ODE).
A list with elements
the transition matrix, and
the discrete process covariance
The EKF/UKF Toolbox was written by Simo Särkkä, Jouni Hartikainen, and Arno Solin.
Dirk Eddelbuettel is porting this package to R and C++, and maintaing it.
The documentation for the EKF/UKF toolbox at http://becs.aalto.fi/en/research/bayes/ekfukf
This function computes the Rauch-Tung-Striebel smoother.
rtsSmoother(M, P, A, Q)
rtsSmoother(M, P, A, Q)
M |
An N x K matrix of K mean estimates from the Kalman Filter |
P |
An N x N x K cube length K with N x N state covariances matrices from the Kalman Filter |
A |
An N x N state transition matrix (or in the more general case a list of K such matrices; not yet implemented) |
Q |
An N x N noise covariance matrix (or in the more general case a list of K such matrices; not yet implemented) |
This function implements the Rauch-Tung-Striebel smoother algorithm which calculate a “smoothed” sequence from the given Kalman filter output sequence by conditioning all steps to all measurements.
A list with three elements
the smoothed mean sequence,
the smooted state covariance sequence,and
the smoothed gain sequence.
The EKF/UKF Toolbox was written by Simo Särkkä, Jouni Hartikainen, and Arno Solin.
Dirk Eddelbuettel is porting this package to R and C++, and maintaing it.
kfPredict, kfUpdate, and the documentation for the EKF/UKF toolbox at http://becs.aalto.fi/en/research/bayes/ekfukf
This function computes the ‘Two filter-based’ Smoother
tfSmoother(M, P, Y, A, Q, H, R, useinf)
tfSmoother(M, P, Y, A, Q, H, R, useinf)
M |
An N x K matrix of K mean estimates from Kalman filter |
P |
An N x N x K matrix of K state covariances from Kalman Filter |
Y |
A D x K matrix of K measurement sequences |
A |
A N x N state transition matrix. |
Q |
A N x N process noise covariance matrix. |
H |
A D x N measurement matrix. |
R |
A D x D measurement noise covariance. |
useinf |
An optional boolean variable indicating if information
filter should be used (with default |
This function implements the two filter linear smoother which calculates a “smoothed” sequence from the given Kalman filter output sequence by conditioning all steps to all measurements.
A list with two elements
the smoothed state mean sequence, and
the smoothes state covariance sequence.
The EKF/UKF Toolbox was written by Simo Särkkä, Jouni Hartikainen, and Arno Solin.
Dirk Eddelbuettel is porting this package to R and C++, and maintaing it.
kfPredict, kfUpdate, and the documentation for the EKF/UKF toolbox at http://becs.aalto.fi/en/research/bayes/ekfukf