KalmanODESolution¶
-
class
probnum.diffeq.
KalmanODESolution
(kalman_posterior)[source]¶ Bases:
probnum.diffeq.odesolution.ODESolution
Gaussian IVP filtering solution of an ODE problem.
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 anIntegrator
.
See also
GaussianIVPFilter
ODE solver that behaves like a Gaussian filter.
KalmanPosterior
Posterior over states after Gaussian filtering/smoothing.
Examples
>>> from probnum.diffeq import logistic, 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
Methods Summary
__call__
(t)Evaluate the time-continuous posterior at location t
interpolate
(t[, previous_location, …])Evaluate the posterior at a measurement-free point.
sample
([t, size, random_state])Sample from the ODE solution.
Transform a set of realizations from a base measure into realizations from the posterior.
Attributes Documentation
-
filtering_solution
¶
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
-
interpolate
(t, previous_location=None, previous_state=None, next_location=None, next_state=None)[source]¶ Evaluate the posterior at a measurement-free point.
- Parameters
t (
Real
) – Location to evaluate at.- Returns
Dense evaluation.
- Return type
randvars.RandomVariable or _randomvariablelist._RandomVariableList
-
sample
(t=None, size=(), random_state=None)[source]¶ Sample from the ODE solution.
- Parameters
t (
Union
[Real
,ndarray
,None
]) – Location / time at which to sample. If nothing is specified, samples at the ODE-solver grid points are computed. If it is a float, a sample of the ODE-solution at this time point is computed. Similarly, if it is a list of floats (or an array), samples at the specified grid-points are returned. This is not the same as computing i.i.d samples at the respective locations.size (
Union
[Integral
,Iterable
[Integral
],None
]) – Number of samples.random_state (
Union
[None
,int
,RandomState
,Generator
]) – Random state used for sampling.
- Return type