with \(H_{k} = \frac{\partial h}{x}\) evaluated at
\(\hat{x}_{k}^{-}\).
The Extended Kalman Filter can deal with non-linear systems but it does not
guarantee an optimal estimation unless the system is linear and the noises
are drawn from a normal distribution, which will cause the Extended Kalman
Filter to behave as a standard Kalman Filter.
Parameters:
xk (numpy.ndarray) – Initial (\(k=0\)) mean estimate.
Q (numpy.ndarray) – Process noise covariance (transition covariance).
R (numpy.ndarray or float.) – Measurement noise covariance (observation covariance).
f (function) – Non-linear state transition function. It is a nonlinear function that
relates the state at the previous time step \(k-1\) to state at the
current step \(k\). It must receive two arguments: \(xk\) and
\(uk\), which are the state and the control-input.
h (function) – Non-linear observation function. It is a nonlinear function that
relates the prior state \(xk\) to the measurement \(zk\). It
must receive one argument: \(xk\).
jacobian_A (function) – The function that computes the jacobian of \(f\) with respect to
\(x\). It must receive two arguments: \(x\) and \(u\).
jacobian_H (function) – The function that computes the jacobian of \(h\) with respect to
\(x\). It must receive one argument: \(x\).
Applies the filtering process over \(Z\) and \(U\) and returns
all errors and covariances. That is: given \(Z\) and \(U\),
this function applies the predict and update feedback loop for each
\(zk\), where \(k\) is a timestamp.
Parameters:
Z (numpy.ndarray) – Observed variable
U (numpy.ndarray, optional, default: None) – Control-input vector.
Returns:
states (list of numpy.ndarray) – A posteriori state estimates for each time step \(k\).
errors (list of numpy.ndarray) – A posteriori estimate error covariances for each time step
\(k\).
Here, the output are the a posteriori or corrected estimates of the
mean \(\hat{x}_{k}\) and covariance \(P_k\).
Parameters:
xk (numpy.ndarray) – Prior mean state estimate at time \(k\).
Pk (numpy.ndarray) – Prior covariance state estimate at time \(k\).
zk (numpy.ndarray) – Observation at time \(k\).
Rk (numpy.ndarray) – Measurement noise covariance at time \(k\).
Returns:
xk_posterior (numpy.ndarray) – A posteriori estimate error mean at time \(k\).
Pk_posterior (numpy.ndarray) – A posteriori estimate error covariance at time \(k\).
Notes
The original formula to compute the Kalman gain would be implemented as
Kk = Pk @ (Hk.T @ np.linalg.pinv(Sk)). Instead, a linear matrix is
solved due to being a more efficient and precise way.
Applies the filtering process over \(Z\) and \(U\) and returns
all errors and covariances. That is: given \(Z\) and \(U\),
this function applies the predict and update feedback loop for each
\(zk\), where \(k\) is a timestamp.
Parameters:
Z (numpy.ndarray) – Observed variable
U (numpy.ndarray, optional, default: None) – Control-input vector.
Returns:
states (list of numpy.ndarray) – A posteriori state estimates for each time step \(k\).
errors (list of numpy.ndarray) – A posteriori estimate error covariances for each time step
\(k\).
Here, the output are the a posteriori or corrected estimates of the
mean \(\hat{x}_{k}\) and covariance \(P_k\).
Parameters:
Hk (numpy.ndarray) – Observation matrix at time \(k\).
xk (numpy.ndarray) – Prior mean state estimate at time \(k\).
Pk (numpy.ndarray) – Prior covariance state estimate at time \(k\).
zk (numpy.ndarray) – Observation at time \(k\).
Rk (numpy.ndarray) – Measurement noise covariance at time \(k\).
Returns:
xk_posterior (numpy.ndarray) – A posteriori estimate error mean at time \(k\).
Pk_posterior (numpy.ndarray) – A posteriori estimate error covariance at time \(k\).
Notes
The original formula to compute the Kalman gain would be implemented as
Kk = Pk @ (Hk.T @ np.linalg.pinv(Sk)). Instead, a linear matrix is
solved due to being a more efficient and precise way.