Prior classes

The inference.priors module provides tools for constructing prior distributions over the model variables. Example code demonstrating their use can be found in the Gaussian fitting jupyter notebook demo.

GaussianPrior

class inference.priors.GaussianPrior(mean: ndarray, sigma: ndarray, variable_indices: list[int])

A class for generating a Gaussian prior for one or more of the model variables.

Parameters:
  • mean – The means of the Gaussian priors on each of the variables specified in the variable_indices argument as a 1D numpy.ndarray.

  • sigma – The standard deviations of the Gaussian priors on each of the variables specified in the variable_indices argument as a 1D numpy.ndarray.

  • variable_indices – A list of integers specifying the indices of the variables to which the prior will apply.

__call__(theta: ndarray) float

Returns the prior log-probability value for the provided set of model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The prior log-probability value.

gradient(theta: ndarray) ndarray

Returns the gradient of the prior log-probability with respect to the model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The gradient of the prior log-probability with respect to the model parameters.

sample() ndarray

Draws a sample from the prior.

Returns:

A single sample from the prior distribution as a 1D numpy.ndarray.

UniformPrior

class inference.priors.UniformPrior(lower: ndarray, upper: ndarray, variable_indices: list[int])

A class for generating a uniform prior for one or more of the model variables.

Parameters:
  • lower – The lower bound of the uniform priors on each of the variables specified in the variable_indices argument as a 1D numpy.ndarray.

  • upper – The upper bound of the uniform priors on each of the variables specified in the variable_indices argument as a 1D numpy.ndarray.

  • variable_indices – A list of integers specifying the indices of the variables to which the prior will apply.

__call__(theta: ndarray) float

Returns the prior log-probability value for the provided set of model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The prior log-probability value.

gradient(theta: ndarray) ndarray

Returns the gradient of the prior log-probability with respect to the model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The gradient of the prior log-probability with respect to the model parameters.

sample() ndarray

Draws a sample from the prior.

Returns:

A single sample from the prior distribution as a 1D numpy.ndarray.

ExponentialPrior

class inference.priors.ExponentialPrior(beta: ndarray, variable_indices: list[int])

A class for generating an exponential prior for one or more of the model variables.

Parameters:
  • beta – The ‘beta’ parameter values of the exponential priors on each of the variables specified in the variable_indices argument as a 1D numpy.ndarray.

  • variable_indices – A list of integers specifying the indices of the variables to which the prior will apply.

__call__(theta: ndarray) float

Returns the prior log-probability value for the provided set of model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The prior log-probability value.

gradient(theta: ndarray) ndarray

Returns the gradient of the prior log-probability with respect to the model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The gradient of the prior log-probability with respect to the model parameters.

sample() ndarray

Draws a sample from the prior.

Returns:

A single sample from the prior distribution as a 1D numpy.ndarray.

JointPrior

class inference.priors.JointPrior(components: list[BasePrior], n_variables: int)

A class which combines multiple prior distribution objects into a single joint-prior distribution object.

Parameters:
  • components – A list of prior distribution objects (e.g. GaussianPrior, ExponentialPrior) which will be combined into a single joint-prior object.

  • n_variables (int) – The total number of model variables.

__call__(theta: ndarray) float

Returns the joint-prior log-probability value, calculated as the sum of the log-probabilities from each prior component for the provided set of model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The prior log-probability value.

gradient(theta: ndarray) ndarray

Returns the gradient of the prior log-probability with respect to the model parameters.

Parameters:

theta – The model parameters as a 1D numpy.ndarray.

Returns:

The gradient of the prior log-probability with respect to the model parameters.

sample() ndarray

Draws a sample from the prior.

Returns:

A single sample from the prior distribution as a 1D numpy.ndarray.