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') where L is a scalar value and L' is a sequence of length n_parameters.

Note that the derivative returned is of the log-pdf, so L' = d/dp log(f(p)), evaluated at p=x.

This is an optional method that is not always implemented.

n_parameters()

Returns the dimension of the space this LogPDF is defined over.

sample(n_samples)[source]

Generates independent samples from the underlying distribution.

suggested_bounds()[source]

Returns suggested boundaries for prior.

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.

suggested_parameters()[source]

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()[source]

Returns an NumPy array of time points that is representative of the model

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 or pints.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 a pints.ForwardModelS1.

_dfdp(y, t, p)[source]

Returns the derivative of the ODE RHS at time t, with respect to model parameters p.

Parameters:
  • y – The state vector at time t (with length n_outputs).

  • t – The time to evaluate at (as a scalar).

  • p – A vector of model parameters (of length n_parameters).

Return type:

A matrix of dimensions n_outputs by n_parameters.

_rhs(y, t, p)[source]

Returns the evaluated RHS (dy/dt) for a given state vector y, time t, and parameter vector p.

Parameters:
  • y – The state vector at time t (with length n_outputs).

  • t – The time to evaluate at (as a scalar).

  • p – A vector of model parameters (of length n_parameters).

Return type:

A vector of length n_outputs.

initial_conditions()[source]

Returns the initial conditions of the model.

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 length n_outputs).

  • t – The time to evaluate at (as a scalar).

  • p – A vector of model parameters (of length n_parameters).

Return type:

A matrix of dimensions n_outputs by n_outputs.

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.

set_initial_conditions(y0)[source]

Sets the initial conditions of the model.

simulate(parameters, times)[source]

See pints.ForwardModel.simulate().

simulateS1(parameters, times)[source]

See pints.ForwardModelS1.simulateS1().

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