ODEFilterSolution

class probnum.diffeq.odefilter.ODEFilterSolution(kalman_posterior)

Bases: probnum.diffeq.ODESolution

Probabilistic ODE solution corresponding to the ODEFilter.

Recall that in ProbNum, Gaussian filtering and smoothing is generally named “Kalman”.

Parameters

kalman_posterior (KalmanPosterior) – Gauss-Markov posterior over the ODE solver state space model. Therefore, it assumes that the dynamics model is an Integrator.

See also

ODEFilter

ODE solver that behaves like a Gaussian filter.

KalmanPosterior

Posterior over states after Gaussian filtering/smoothing.

Examples

>>> import numpy as np
>>> from probnum.diffeq import probsolve_ivp
>>> from probnum import randvars
>>>
>>> def f(t, x):
...     return 4*x*(1-x)
>>>
>>> y0 = np.array([0.15])
>>> t0, tmax = 0., 1.5
>>> solution = probsolve_ivp(f, t0, tmax, y0, step=0.1, adaptive=False)
>>> # Mean of the discrete-time solution
>>> print(np.round(solution.states.mean, 2))
[[0.15]
 [0.21]
 [0.28]
 [0.37]
 [0.47]
 [0.57]
 [0.66]
 [0.74]
 [0.81]
 [0.87]
 [0.91]
 [0.94]
 [0.96]
 [0.97]
 [0.98]
 [0.99]]
>>> # Times of the discrete-time solution
>>> print(solution.locations)
[0.  0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.  1.1 1.2 1.3 1.4 1.5]
>>> # Individual entries of the discrete-time solution can be accessed with
>>> print(solution[5])
<Normal with shape=(1,), dtype=float64>
>>> print(np.round(solution[5].mean, 2))
[0.56]
>>> # Evaluate the continuous-time solution at a new time point t=0.65
>>> print(np.round(solution(0.65).mean, 2))
[0.70]

Attributes Summary

filtering_solution

frozen

Whether the posterior is frozen.

locations

Locations of the states of the posterior.

states

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])

Sample from the ODE solution.

transform_base_measure_realizations(...[, t])

Transform base-measure-realizations into posteriors samples.

Attributes Documentation

filtering_solution
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 (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – 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

randvars.RandomVariable or randvars._RandomVariableList

append(location, state)

Append a state to the posterior.

Return type

None

freeze()

Freeze the posterior.

Return type

None

interpolate(t, previous_index=None, next_index=None)[source]

Evaluate the posterior at a measurement-free point.

Returns

Dense evaluation.

Return type

randvars.RandomVariable or randvars._RandomVariableList

sample(rng, t=None, size=())[source]

Sample from the ODE solution.

Parameters
Return type

ndarray

transform_base_measure_realizations(base_measure_realizations, t=None)[source]

Transform base-measure-realizations into posteriors samples.

Parameters
Returns

Transformed realizations.

Return type

np.ndarray