Kalman¶
-
class
probnum.filtsmooth.
Kalman
(dynamics_model, measurement_model, initrv)[source]¶ Bases:
probnum.filtsmooth.bayesfiltsmooth.BayesFiltSmooth
Gaussian filtering and smoothing, i.e. Kalman-like filters and smoothers.
Methods Summary
condition_state_on_measurement
(randvar, …)Condition the state on the observed data.
filter
(dataset, times[, intermediate_step, …])Apply Gaussian filtering (no smoothing!) to a data set.
filter_step
(start, stop, current_rv, data[, …])A single filter step.
filtsmooth
(dataset, times[, intermediate_step])Apply Gaussian filtering and smoothing to a data set.
measure
(time, randvar)Propagate the state through the measurement model.
predict
(start, stop, randvar[, …])smooth
(filter_posterior[, intermediate_step])Apply Gaussian smoothing to the filtering outcome (i.e.
smooth_list
(rv_list, locations[, …])Apply smoothing to a list of RVs with desired final random variable.
smooth_step
(unsmoothed_rv, smoothed_rv, …)A single smoother step.
smoother_step
(**kwargs)Smoother step.
update
(time, randvar, data)Gaussian filter update step.
Methods Documentation
-
condition_state_on_measurement
(randvar, meas_rv, data, crosscov)[source]¶ Condition the state on the observed data.
- Parameters
randvar (Normal) – Random variable to be updated with the measurement and data.
meas_rv (Normal) – Measured random variable, as returned by the measurement model.
data (np.ndarray) – Data to update on.
crosscov (np.ndarray) – Cross-covariance between the state random variable randvar and the measurement random variable meas_rv.
- Returns
Updated Normal random variable (new filter estimate)
- Return type
-
filter
(dataset, times, intermediate_step=None, linearise_at=None)[source]¶ Apply Gaussian filtering (no smoothing!) to a data set.
- Parameters
dataset (array_like, shape (N, M)) – Data set that is filtered.
times (array_like, shape (N,)) – Temporal locations of the data points.
- Returns
Posterior distribution of the filtered output
- Return type
-
filter_step
(start, stop, current_rv, data, intermediate_step=None)[source]¶ A single filter step.
Consists of a prediction step (t -> t+1) and an update step (at t+1).
- Parameters
start (float) – Predict FROM this time point.
stop (float) – Predict TO this time point.
current_rv (RandomVariable) – Predict based on this random variable. For instance, this can be the result of a previous call to filter_step.
data (array_like) – Compute the update based on this data.
- Returns
RandomVariable – Resulting filter estimate after the single step.
dict – Additional information provided by predict() and update(). Contains keys pred_rv, info_pred, meas_rv, info_upd.
-
filtsmooth
(dataset, times, intermediate_step=None)[source]¶ Apply Gaussian filtering and smoothing to a data set.
- Parameters
dataset (array_like, shape (N, M)) – Data set that is filtered.
times (array_like, shape (N,)) – Temporal locations of the data points.
- Returns
Posterior distribution of the smoothed output
- Return type
-
measure
(time, randvar)[source]¶ Propagate the state through the measurement model.
- Parameters
- Returns
meas_rv (Normal) – Measured random variable, as returned by the measurement model.
info (dict) – Additional info. Contains at leas the key crosscov which is the cross covariance between the input random variable and the measured random variable.
-
smooth
(filter_posterior, intermediate_step=None)[source]¶ Apply Gaussian smoothing to the filtering outcome (i.e. a KalmanPosterior).
- Parameters
filter_posterior (KalmanPosterior) – Posterior distribution obtained after filtering
intermediate_step – Step-size to be taken by approximate transition methods.
- Returns
Posterior distribution of the smoothed output
- Return type
-
smooth_list
(rv_list, locations, intermediate_step=None)[source]¶ Apply smoothing to a list of RVs with desired final random variable.
Specification of a final RV is useful to compute joint samples from a KalmanPosterior object, because in this case, the final RV is a Dirac (over a sample from the final Normal RV) and not a Normal RV.
- Parameters
rv_list (_RandomVariableList or array_like) – List of random variables to be smoothed.
locations (array_like) – Locations of the random variables in rv_list.
intermediate_step – Step-size to be taken by approximate transition methods.
- Returns
List of smoothed random variables.
- Return type
_RandomVariableList
-
smooth_step
(unsmoothed_rv, smoothed_rv, start, stop, intermediate_step=None)[source]¶ A single smoother step.
Consists of predicting from the filtering distribution at time t to time t+1 and then updating based on the discrepancy to the smoothing solution at time t+1. If preconditioning is available in the dynamic model, this is leveraged here. If not, a classic smoothing step estimate is taken.
- Parameters
unsmoothed_rv (RandomVariable) – Filtering distribution at time t.
smoothed_rv (RandomVariable) – Prediction at time t+1 of the filtering distribution at time t.
start (float) – Time-point of the to-be-smoothed RV.
stop (float) – Time-point of the already-smoothed RV.
intermediate_step – Step-size to be taken by approximate transition methods.
-
smoother_step
(**kwargs)¶ Smoother step.
-
update
(time, randvar, data)[source]¶ Gaussian filter update step. Consists of a measurement step and a conditioning step.
- Parameters
time (float) – Time of the update.
randvar (RandomVariable) – Random variable to be updated. Result of
predict()
.data (np.ndarray) – Data to update on.
- Returns
filt_rv (Normal) – Updated Normal RV (new filter estimate).
meas_rv (Normal) – Measured random variable, as returned by the measurement model.
info (dict) – Additional info. Contains at least the key crosscov, which is the crosscov between input RV and measured RV. The crosscov does not relate to the updated RV!
-