Boundaries

Diagnostics

# Core classes and methods¶

pints.version(formatted=False)

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

class pints.TunableMethod

Defines an interface for a numerical method with a given number of hyper-parameters.

Each optimiser or sampler method implemented in pints has a number of parameters which alters its behaviour, which can be called “hyper-parameters”. The optimiser/sampler method will provide member functions to set each of these hyper-parameters individually. In contrast, this interface provides a generic way to set the hyper-parameters, which allows the user to, for example, use an optimiser to tune the hyper-parameters of the method.

Note that the set_hyper_parameters function 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()

Returns the number of hyper-parameters for this method (see TunableMethod).

set_hyper_parameters(x)

Sets the hyper-parameters for the method with the given vector of values (see TunableMethod).

Arguments:

x an array of length n_hyper_parameters used to set the
hyper-parameters

## Forward model¶

class pints.ForwardModel

Defines an interface for user-supplied 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).

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 time-series with data points corresponding to the given times.

Arguments:

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:

A sequence of length n_times (for single output problems) or a NumPy array of shape (n_times, n_outputs) (for multi-output problems), representing the values of the model at the given times.

## Forward model with sensitivities¶

class pints.ForwardModelS1

Defines an interface for user-supplied forward models which can calculate the first-order derivative of the simulated values with respect to the parameters.

Derived from 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 time-series with data points corresponding to the given times.

Arguments:

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:

A sequence of length n_times (for single output problems) or a NumPy array of shape (n_times, n_outputs) (for multi-output problems), representing the values of the model at the given times.

simulateS1(parameters, times)

Runs a forward simulation with the given parameters and returns a time-series with data points corresponding to the given times, along with the sensitivities of the forward simulation with respect to the parameters.

Arguments:

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:

A tuple (y, y') of the simulated values y and their derivatives y' with resepect to the parameters. The first entry y must be a sequence of n_times values, or a NumPy array of shape (n_times, n_outputs). The second entry y' must be 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)

Represents an inference problem where a model is fit to a single time series, such as measured from a system with a single output.

Arguments:

model
A model or model wrapper extending ForwardModel.
times
A sequence of points in time. Must be non-negative and increasing.
values
A sequence of scalar output values, measured at the times in times.
evaluate(parameters)

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

evaluateS1(parameters)

Runs a simulation with first-order sensitivity calculation, returning the simulated values and derivatives.

The returned data is a tuple of NumPy arrays (y, y'), where y has shape (self._n_times,) while y' has shape (n_times, n_parameters).

This method only works for problems with a model that implements the :class:ForwardModelS1 interface.

n_outputs()

Returns the number of outputs for this problem (always 1).

n_parameters()

Returns the dimension (the number of parameters) of this problem.

n_times()

Returns the number of sampling points, i.e. the length of the vectors returned by times() and values().

times()

Returns this problem’s times.

The returned value is a read-only NumPy array of shape (n_times, ), where n_times is the number of time points.

values()

Returns this problem’s values.

The returned value is a read-only NumPy array of shape (n_times, ), where n_times is the number of time points.

class pints.MultiOutputProblem(model, times, values)

Represents an inference problem where a model is fit to a multi-valued time series, such as measured from a system with multiple outputs.

Arguments:

model
A model or model wrapper extending ForwardModel.
times
A sequence of points in time. Must be non-negative and non-decreasing.
values
A sequence of multi-valued measurements. Must have shape (n_times, n_outputs), where n_times is the number of points in times and n_outputs is the number of outputs in the model.
evaluate(parameters)

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)

Runs a simulation using the given parameters, returning the simulated values.

The returned data is a tuple of NumPy arrays (y, y'), where y has shape (n_times, n_outputs), while y' has shape (n_times, n_outputs, n_parameters).

This method only works for problems whose model implements the :class:ForwardModelS1 interface.

n_outputs()

Returns the number of outputs for this problem.

n_parameters()

Returns the dimension (the number of parameters) of this problem.

n_times()

Returns the number of sampling points, i.e. the length of the vectors returned by times() and values().

times()

Returns this problem’s times.

The returned value is a read-only NumPy array of shape (n_times, n_outputs), where n_times is the number of time points and n_outputs is the number of outputs.

values()

Returns this problem’s values.

The returned value is a read-only NumPy array of shape (n_times, n_outputs), where n_times is the number of time points and n_outputs is the number of outputs.