# KalmanODESolution¶

class probnum.diffeq.odefiltsmooth.KalmanODESolution(kalman_posterior)

Probabilistic ODE solution corresponding to the `GaussianIVPFilter`.

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

`GaussianIVPFilter`

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)
<Normal with shape=(1,), dtype=float64>
>>> print(np.round(solution.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

Methods Summary

 Evaluate the time-continuous posterior at location t `append`(location, state) rtype `None` rtype `None` `interpolate`(t[, previous_index, next_index]) Evaluate the posterior at a measurement-free point. `sample`(rng[, t, size]) Sample from the ODE solution. Transform a set of realizations from a base measure into realizations from the posterior.

Attributes Documentation

filtering_solution
frozen
locations
states

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`[`Real`, `ndarray`]) – Location, or time, at which to evaluate the posterior.

Returns

Estimate of the states at time `t`.

Return type

randvars.RandomVariable or _randomvariablelist._RandomVariableList

append(location, state)
Return type

`None`

freeze()
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 _randomvariablelist._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 a set of realizations from a base measure into realizations from the posterior.

Parameters
Returns

Transformed realizations.

Return type

np.ndarray