Filters

class kalman.filters.BaseFilter(*args: Any, **kwargs: Any)[source]

Abstract base class for Kalman Filters

forward(observations: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]

Processes an entire sequence of observations in shape (T, B, obs_dim). Returns β€”β€”- all_states, all_states : GaussianState ‑‑ convenient wrapper holding the whole trajectory

predict(state: GaussianState) GaussianState[source]

Single-step predict. Returns:

GaussianStateю

predict_(state_mean: torch.Tensor, state_cov: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]

Internal function for single-step predict. Returns:

predicted_state_mean, predicted_state_cov

predict_update(state: GaussianState, measurement: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]

Single-step predict and update in one function. Returns:

updated_state_mean, updated_state_cov

update(state: GaussianState, measurement: torch.Tensor) GaussianState[source]

Single-step update. Returns:

GaussianStateю

update_(state_mean: torch.Tensor, state_cov: torch.Tensor, measurement: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]

Internal single-step update. Returns:

updated_state_mean, updated_state_cov

class kalman.filters.KalmanFilter(*args: Any, **kwargs: Any)[source]

Kalman Filter class. Attributes:

process_matrix (torch.Tensor): State transition matrix (F)

Shape: (*, state_dim, state_dim)

measurement_matrix (torch.Tensor): Projection matrix (H)

Shape: (*, obs_dim, state_dim)

process_noise (torch.Tensor): Uncertainty on the process (Q)

Shape: (*, state_dim, state_dim)

measurement_noise (torch.Tensor): Uncertainty on the measure (R)

Shape: (*, obs_dim, obs_dim)

forward(observations: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]

Run the Kalman Filter over a sequence of observations.

predict(state: GaussianState, *, process_matrix: torch.Tensor | None = None, process_noise: torch.Tensor | None = None) GaussianState[source]

Predict step of the Kalman Filter. Initially state_mean is (B, state_dim)

project(state: GaussianState, *, measurement_matrix: torch.Tensor | None = None, measurement_noise: torch.Tensor | None = None, precompute_precision=True) GaussianState[source]

Project the current state (usually the prior) onto the measurement space Args:

state (GaussianState): Current state estimation (Usually the results of predict) measurement_matrix (Optional[torch.Tensor]): Overwrite the default projection matrix

Shape: (*, bs, state_dim)

measurement_noise (Optional[torch.Tensor]): Overwrite the default projection noise)

Shape: (*, obs_dim, obs_dim)

precompute_precision (bool): Precompute precision matrix (inverse covariance)

Done once to prevent more computations Default: True

Returns:

GaussianState: Prior on the next state

update(state: GaussianState, measurement: torch.Tensor, *, projection: GaussianState | None = None, measurement_matrix: torch.Tensor | None = None, measurement_noise: torch.Tensor | None = None) GaussianState

Update step of the Kalman Filter.