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Ρ
- 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.