KalmanPosterior¶
- class probnum.filtsmooth.gaussian.KalmanPosterior(transition, locations=None, states=None, diffusion_model=None)¶
Bases:
TimeSeriesPosterior
,ABC
Posterior distribution after approximate Gaussian filtering and smoothing.
- Parameters
locations (Optional[Iterable[FloatLike]]) – Locations / Times of the discrete-time estimates.
states (Optional[Iterable[randvars.RandomVariable]]) – Estimated states (in the state-space model view) of the discrete-time estimates.
transition (GaussMarkovPriorTransitionArgType) – Dynamics model used as a prior for the filter.
- Return type
None
Attributes Summary
Whether the posterior is frozen.
Locations of the states of the posterior.
States of the posterior.
Methods Summary
__call__
(t)Evaluate the time-continuous posterior at location t
append
(location, state)Append a state to the posterior.
freeze
()Freeze the posterior.
interpolate
(t[, previous_index, next_index])Evaluate the posterior at a measurement-free point.
sample
(rng[, t, size])Draw samples from the filtering/smoothing posterior.
Transform samples from a base measure to samples from the KalmanPosterior.
Attributes Documentation
- frozen¶
Whether the posterior is frozen.
- locations¶
Locations of the states of the posterior.
- states¶
States of the posterior.
Methods Documentation
- __call__(t)¶
Evaluate the time-continuous posterior at location t
Algorithm: 1. Find closest t_prev and t_next, with t_prev < t < t_next 2. Predict from t_prev to t 3. (if self._with_smoothing=True) Predict from t to t_next 4. (if self._with_smoothing=True) Smooth from t_next to t 5. Return random variable for time t
- Parameters
t (ArrayLike) – Location, or time, at which to evaluate the posterior.
- Raises
ValueError – If time-points are not strictly increasing.
- Returns
Estimate of the states at time
t
.- Return type
- append(location, state)¶
Append a state to the posterior.
- Parameters
location (FloatLike) –
state (RandomVariable) –
- Return type
None
- freeze()¶
Freeze the posterior.
- Return type
None
- abstract interpolate(t, previous_index=None, next_index=None)[source]¶
Evaluate the posterior at a measurement-free point.
- Returns
Dense evaluation.
- Return type
- Parameters
t (FloatLike) –
previous_index (Optional[IntLike]) –
next_index (Optional[IntLike]) –
- sample(rng, t=None, size=())[source]¶
Draw samples from the filtering/smoothing posterior.
If nothing is specified, a single sample is drawn (supported on self.locations). If locations are specified, a single sample is drawn on those locations. If size is specified, more than a single sample is drawn.
Internally, samples from a base measure are drawn and transformed via self.transform_base_measure_realizations.
- Parameters
rng (np.random.Generator) – Random number generator.
t (Optional[ArrayLike]) – Locations on which the samples are wanted. Default is none, which implies that self.location is used.
size (Optional[ShapeLike]) – Indicates how many samples are drawn. Default is an empty tuple, in which case a single sample is returned.
- Returns
Drawn samples. If size has shape (A1, …, Z1), locations have shape (L,), and the state space model has shape (A2, …, Z2), the output has shape (A1, …, Z1, L, A2, …, Z2). For example: size=4, len(locations)=4, dim=3 gives shape (4, 4, 3).
- Return type
np.ndarray
- abstract transform_base_measure_realizations(base_measure_realizations, t)[source]¶
Transform samples from a base measure to samples from the KalmanPosterior.
Here, the base measure is a multivariate standard Normal distribution.
- Parameters
base_measure_realizations (ndarray) – Shape (*size, N, d). Samples from a multivariate standard Normal distribution. N is either the len(self.locations) (if t == None), or len(t) + 1 (if t != None). The reason for the +1 in the latter is that samples at arbitrary locations need to be conditioned on a sample at the final time point.
t (ArrayLike) – Shape (N,). Time points. Must include self.locations.Shape
- Returns
Shape (*size, N, d) Transformed base measure realizations. If the inputs are samples from a multivariate standard Normal distribution, the results are size samples from the Kalman posterior at prescribed locations.
- Return type
np.ndarray