Core classes and methods¶
Pints provides the SingleOutputProblem
and
MultiOutputProblem
classes to formulate
inverse problems based on time series data and
ForwardModel
.
Overview:

pints.
version
(formatted=False)[source]¶ Returns the version number, as a 3part integer (major, minor, revision). If
formatted=True
, it returns a string formatted version (for example “Pints 1.0.0”).

class
pints.
TunableMethod
[source]¶ Defines an interface for a numerical method with a given number of hyperparameters.
Each optimiser or sampler method implemented in pints has a number of parameters which alters its behaviour, which can be called “hyperparameters”. The optimiser/sampler method will provide member functions to set each of these hyperparameters individually. In contrast, this interface provides a generic way to set the hyperparameters, which allows the user to, for example, use an optimiser to tune the hyperparameters of the method.
Note that
set_hyper_parameters()
takes an array of parameters, which might be of the same type (e.g. a NumPy array). So derived classes should not raise any errors if individual hyper parameters are set using the wrong type (e.g. float rather than int), but should instead implicitly convert the argument to the correct type.
n_hyper_parameters
()[source]¶ Returns the number of hyperparameters for this method (see
TunableMethod
).

set_hyper_parameters
(x)[source]¶ Sets the hyperparameters for the method with the given vector of values (see
TunableMethod
).Parameters: x – An array of length n_hyper_parameters
used to set the hyperparameters.

Forward model¶

class
pints.
ForwardModel
[source]¶ Defines an interface for usersupplied forward models.
Classes extending
ForwardModel
can implement the required methods directly in Python or interface with other languages (for example via Python wrappers around C code).
simulate
(parameters, times)[source]¶ Runs a forward simulation with the given
parameters
and returns a timeseries with data points corresponding to the giventimes
.Returns a sequence of length
n_times
(for single output problems) or a NumPy array of shape(n_times, n_outputs)
(for multioutput problems), representing the values of the model at the giventimes
.Parameters:  parameters – An ordered sequence of parameter values.
 times – The times at which to evaluate. Must be an ordered sequence,
without duplicates, and without negative values.
All simulations are started at time 0, regardless of whether this
value appears in
times
.

Forward model with sensitivities¶

class
pints.
ForwardModelS1
[source]¶ Defines an interface for usersupplied forward models which can calculate the firstorder derivative of the simulated values with respect to the parameters.
Extends
pints.ForwardModel
.
n_outputs
()¶ Returns the number of outputs this model has. The default is 1.

n_parameters
()¶ Returns the dimension of the parameter space.

simulate
(parameters, times)¶ Runs a forward simulation with the given
parameters
and returns a timeseries with data points corresponding to the giventimes
.Returns a sequence of length
n_times
(for single output problems) or a NumPy array of shape(n_times, n_outputs)
(for multioutput problems), representing the values of the model at the giventimes
.Parameters:  parameters – An ordered sequence of parameter values.
 times – The times at which to evaluate. Must be an ordered sequence,
without duplicates, and without negative values.
All simulations are started at time 0, regardless of whether this
value appears in
times
.

simulateS1
(parameters, times)[source]¶ Runs a forward simulation with the given
parameters
and returns a timeseries with data points corresponding to the giventimes
, along with the sensitivities of the forward simulation with respect to the parameters.Parameters:  parameters – An ordered list of parameter values.
 times – The times at which to evaluate. Must be an ordered sequence,
without duplicates, and without negative values.
All simulations are started at time 0, regardless of whether this
value appears in
times
.
Returns:  y – The simulated values, as a sequence of
n_times
values, or a NumPy array of shape(n_times, n_outputs)
.  y’ – The corresponding derivatives, as a NumPy array of shape
(n_times, n_parameters)
or an array of shape(n_times, n_outputs, n_parameters)
.

Problems¶

class
pints.
SingleOutputProblem
(model, times, values)[source]¶ Represents an inference problem where a model is fit to a single time series, such as measured from a system with a single output.
Parameters:  model – A model or model wrapper extending
ForwardModel
.  times – A sequence of points in time. Must be nonnegative and increasing.
 values – A sequence of scalar output values, measured at the times in
times
.

evaluate
(parameters)[source]¶ Runs a simulation using the given parameters, returning the simulated values as a NumPy array of shape
(n_times,)
.

evaluateS1
(parameters)[source]¶ Runs a simulation with firstorder sensitivity calculation, returning the simulated values and derivatives.
The returned data is a tuple of NumPy arrays
(y, y')
, wherey
has shape(self._n_times,)
whiley'
has shape(n_times, n_parameters)
.This method only works for problems with a model that implements the :class:`ForwardModelS1` interface.

n_times
()[source]¶ Returns the number of sampling points, i.e. the length of the vectors returned by
times()
andvalues()
.
 model – A model or model wrapper extending

class
pints.
MultiOutputProblem
(model, times, values)[source]¶ Represents an inference problem where a model is fit to a multivalued time series, such as measured from a system with multiple outputs.
Parameters:  model – A model or model wrapper extending
ForwardModel
.  times – A sequence of points in time. Must be nonnegative and nondecreasing.
 values – A sequence of multivalued measurements. Must have shape
(n_times, n_outputs)
, wheren_times
is the number of points intimes
andn_outputs
is the number of outputs in the model.

evaluate
(parameters)[source]¶ Runs a simulation using the given parameters, returning the simulated values.
The returned data is a NumPy array with shape
(n_times, n_outputs)
.

evaluateS1
(parameters)[source]¶ Runs a simulation using the given parameters, returning the simulated values.
The returned data is a tuple of NumPy arrays
(y, y')
, wherey
has shape(n_times, n_outputs)
, whiley'
has shape(n_times, n_outputs, n_parameters)
.This method only works for problems whose model implements the :class:`ForwardModelS1` interface.

n_times
()[source]¶ Returns the number of sampling points, i.e. the length of the vectors returned by
times()
andvalues()
.
 model – A model or model wrapper extending