ODESolution¶
- class probnum.diffeq.ODESolution(locations, states, derivatives=None)¶
Bases:
probnum.filtsmooth.TimeSeriesPosterior
Interface for ODE solutions in ProbNum.
- Parameters
locations (
ndarray
) – Locations of the time-grid that was used by the ODE solver.states (
_RandomVariableList
) – Output of the ODE solver at the locations.derivatives (
Optional
[_RandomVariableList
]) – Derivatives of the states at the locations. Optional. Default is None. Some ODE solvers provide these estimates, others do not.
Attributes Summary
Methods Summary
__call__
(t)Evaluate the time-continuous posterior at location t
append
(location, state)- rtype
freeze
()- rtype
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
- 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
- interpolate(t, previous_index=None, next_index=None)[source]¶
Evaluate the posterior at a measurement-free point.
- Returns
Dense evaluation.
- Return type
- sample(rng, t=None, size=())[source]¶
Sample from the ODE solution.
- Parameters
rng (
Generator
) – Random number generator.t (
Union
[_SupportsArray
[dtype
],_NestedSequence
[_SupportsArray
[dtype
]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]],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
[int
,Integral
,integer
,Iterable
[Union
[int
,Integral
,integer
]],None
]) – Number of samples.
- Return type
- transform_base_measure_realizations(base_measure_realizations, t)[source]¶
Transform a set of realizations from a base measure into realizations from the posterior.
- Parameters
base_measure_realizations (
ndarray
) – Base measure realizations.t (
Union
[_SupportsArray
[dtype
],_NestedSequence
[_SupportsArray
[dtype
]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – Locations on which the transformed realizations shall represent realizations from the posterior.
- Returns
Transformed realizations.
- Return type
np.ndarray