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, sigma, variable_indices)

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

Parameters
  • mean – A list specifying the means of the Gaussian priors on each of the variables specified in the variable_indices argument.

  • sigma – A list specifying the standard deviations of the Gaussian priors on each of the variables specified in the variable_indices argument.

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

__call__(theta)

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)

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()

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, upper, variable_indices)

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

Parameters
  • lower – A list specifying the lower bound of the uniform priors on each of the variables specified in the variable_indices argument.

  • upper – A list specifying the upper bound of the uniform priors on each of the variables specified in the variable_indices argument.

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

__call__(theta)

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)

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()

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, variable_indices)

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

Parameters
  • beta – A list specifying the ‘beta’ parameter value of the exponential priors on each of the variables specified in the variable_indices argument.

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

__call__(theta)

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)

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()

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, n_variables)

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)

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)

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()

Draws a sample from the prior.

Returns

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