Extended Kalman filter

Contents

Extended Kalman filter#

class c4dynamics.filters.ekf.ekf(X: dict, P0: ndarray, F: ndarray | None = None, H: ndarray | None = None, G: ndarray | None = None, Q: ndarray | None = None, R: ndarray | None = None)[source]#

Extended Kalman Filter class for handling nonlinear dynamics by incorporating functions for nonlinear state transitions and measurements.

This subclass extends the base kalman class to handle cases where system dynamics or measurements are nonlinear. The Jacobian matrices F and H can be dynamically updated as linearizations of the nonlinear functions.

Parameters:
  • X (dict) – Initial state estimate dictionary, where key-value pairs represent state variables and their initial values.

  • P0 (np.ndarray) – Initial error covariance matrix, defining the initial uncertainty for each state variable.

  • F (np.ndarray, optional) – State transition Jacobian matrix; defaults to an identity matrix if not provided, assuming a linear system model.

  • H (np.ndarray, optional) – Measurement Jacobian matrix; defaults to a zero matrix if not provided.

  • G (np.ndarray, optional) – Control input matrix, mapping control inputs to the state.

  • Q (np.ndarray, optional) – Process noise covariance matrix.

  • R (np.ndarray, optional) – Measurement noise covariance matrix.

Example

A detailed example can be found in the introduction to the c4dynamics.filters module. The mechanism of this class is similar to the kalman, so the examples provided there may serve as inspiration for using ekf.

Methods

ekf.predict([F, fx, dt, u, Q])

Predicts the next state of the system based on the current state and an optional nonlinear state transition function.

ekf.update(z[, H, hx, R])

Updates the state estimate based on the latest measurement, using an optional nonlinear measurement function.

ekf.store([t])

Stores the current state and diagonal elements of the covariance matrix.