Toy base classes¶
-
class
pints.toy.
ToyLogPDF
[source]¶ Abstract base class for toy distributions.
Extends
pints.LogPDF
.-
distance
(samples)[source]¶ Calculates a measure of distance from
samples
to some characteristic of the underlying distribution.
-
evaluateS1
(x)¶ Evaluates this LogPDF, and returns the result plus the partial derivatives of the result with respect to the parameters.
The returned data is a tuple
(L, L')
whereL
is a scalar value andL'
is a sequence of lengthn_parameters
.Note that the derivative returned is of the log-pdf, so
L' = d/dp log(f(p))
, evaluated atp=x
.This is an optional method that is not always implemented.
-
n_parameters
()¶ Returns the dimension of the space this
LogPDF
is defined over.
-
-
class
pints.toy.
ToyModel
[source]¶ Defines an interface for toy problems.
Note that toy models should extend both
ToyModel
and one of the forward model classes, e.g.pints.ForwardModel
.
-
class
pints.toy.
ToyODEModel
[source]¶ Defines an interface for toy problems where the underlying model is an ordinary differential equation (ODE) that describes some time-series generating model.
Note that toy ODE models should extend both
pints.ToyODEModel
and one of the forward model classes, e.g.pints.ForwardModel
orpints.ForwardModelS1
.To use this class as the basis for a
pints.ForwardModel
, the method_rhs()
should be reimplemented.Models implementing
_rhs()
,jacobian()
and_dfdp()
can be used to create apints.ForwardModelS1
.-
_dfdp
(y, t, p)[source]¶ Returns the derivative of the ODE RHS at time
t
, with respect to model parametersp
.Parameters: - y – The state vector at time
t
(with lengthn_outputs
). - t – The time to evaluate at (as a scalar).
- p – A vector of model parameters (of length
n_parameters
).
Returns: Return type: A matrix of dimensions
n_outputs
byn_parameters
.- y – The state vector at time
-
_rhs
(y, t, p)[source]¶ Returns the evaluated RHS (
dy/dt
) for a given state vectory
, timet
, and parameter vectorp
.Parameters: - y – The state vector at time
t
(with lengthn_outputs
). - t – The time to evaluate at (as a scalar).
- p – A vector of model parameters (of length
n_parameters
).
Returns: Return type: A vector of length
n_outputs
.- y – The state vector at time
-
jacobian
(y, t, p)[source]¶ Returns the Jacobian (the derivative of the RHS ODE with respect to the outputs) at time
t
.Parameters: - y – The state vector at time
t
(with lengthn_outputs
). - t – The time to evaluate at (as a scalar).
- p – A vector of model parameters (of length
n_parameters
).
Returns: Return type: A matrix of dimensions
n_outputs
byn_outputs
.- y – The state vector at time
-
n_states
()[source]¶ Returns number of states in underlying ODE. Note: will not be same as
n_outputs()
for models where only a subset of states are observed.
-
suggested_parameters
()¶ Returns an NumPy array of the parameter values that are representative of the model.
For example, these parameters might reproduce a particular result that the model is famous for.
-
suggested_times
()¶ Returns an NumPy array of time points that is representative of the model
-