pybop.parameters.priors#

Classes#

BasePrior

A base class for defining prior distributions.

Exponential

Represents an exponential distribution with a specified scale parameter.

Gaussian

Represents a Gaussian (normal) distribution with a given mean and standard deviation.

JointLogPrior

Represents a joint prior distribution composed of multiple prior distributions.

Uniform

Represents a uniform distribution over a specified interval.

Module Contents#

class pybop.parameters.priors.BasePrior[source]#

A base class for defining prior distributions.

This class provides a foundation for implementing various prior distributions. It includes methods for calculating the probability density function (PDF), log probability density function (log PDF), and generating random variates from the distribution.

prior#

The underlying continuous random variable distribution.

Type:

scipy.stats.rv_continuous

loc#

The location parameter of the distribution.

Type:

float

scale#

The scale parameter of the distribution.

Type:

float

__call__(x)[source]#

Evaluates the distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the distribution.

Returns:

The value(s) of the distribution at x.

Return type:

float

__repr__()[source]#

Returns a string representation of the object.

abstract _logpdfS1(x)[source]#

Evaluates the first derivative of the distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the first derivative.

Returns:

The value(s) of the first derivative at x.

Return type:

float

cdf(x)[source]#

Calculates the cumulative distribution function (CDF) of the distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the CDF.

Returns:

The cumulative distribution function value at x.

Return type:

float

icdf(q)[source]#

Calculates the inverse cumulative distribution function (CDF) of the distribution at q.

Parameters:

q (float) – The point(s) at which to evaluate the inverse CDF.

Returns:

The inverse cumulative distribution function value at q.

Return type:

float

logpdf(x)[source]#

Calculates the logarithm of the probability density function of the distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the log pdf.

Returns:

The logarithm of the probability density function value at x.

Return type:

float

logpdfS1(x)[source]#

Evaluates the first derivative of the distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the first derivative.

Returns:

The value(s) of the first derivative at x.

Return type:

float

pdf(x)[source]#

Calculates the probability density function (PDF) of the distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the pdf.

Returns:

The probability density function value at x.

Return type:

float

rvs(size=1, random_state=None)[source]#

Generates random variates from the distribution.

Parameters:
  • size (int) – The number of random variates to generate.

  • random_state (int, optional) – The random state seed for reproducibility. Default is None.

Returns:

An array of random variates from the distribution.

Return type:

array_like

Raises:

ValueError – If the size parameter is negative.

verify(x)[source]#

Verifies that the input is a numpy array and converts it if necessary.

property mean[source]#

Get the mean of the distribution.

Returns:

The mean of the distribution.

Return type:

float

property sigma[source]#

Get the standard deviation of the distribution.

Returns:

The standard deviation of the distribution.

Return type:

float

class pybop.parameters.priors.Exponential(scale, loc=0, random_state=None)[source]#

Bases: BasePrior

Represents an exponential distribution with a specified scale parameter.

This class provides methods to calculate the pdf, the log pdf, and to generate random variates from the distribution.

Parameters:

scale (float) – The scale parameter (lambda) of the exponential distribution.

_logpdfS1(x)[source]#

Evaluates the first derivative of the log exponential distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the first derivative.

Returns:

The value(s) of the first derivative at x.

Return type:

float

_n_parameters = 1[source]#
loc = 0[source]#
name = 'Exponential'[source]#
prior[source]#
scale[source]#
class pybop.parameters.priors.Gaussian(mean, sigma, random_state=None)[source]#

Bases: BasePrior

Represents a Gaussian (normal) distribution with a given mean and standard deviation.

This class provides methods to calculate the probability density function (pdf), the logarithm of the pdf, and to generate random variates (rvs) from the distribution.

Parameters:
  • mean (float) – The mean (mu) of the Gaussian distribution.

  • sigma (float) – The standard deviation (sigma) of the Gaussian distribution.

_logpdfS1(x)[source]#

Evaluates the first derivative of the gaussian (log) distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the first derivative.

Returns:

The value(s) of the first derivative at x.

Return type:

float

_multip[source]#
_n_parameters = 1[source]#
_offset[source]#
loc[source]#
name = 'Gaussian'[source]#
prior[source]#
scale[source]#
sigma2[source]#
class pybop.parameters.priors.JointLogPrior(*priors: BasePrior)[source]#

Bases: BasePrior

Represents a joint prior distribution composed of multiple prior distributions.

Parameters:

priors (BasePrior) – One or more prior distributions to combine into a joint distribution.

__repr__() str[source]#

Returns a string representation of the object.

_logpdfS1(x: float | numpy.ndarray) tuple[float, numpy.ndarray][source]#

Evaluates the first derivative of the joint log-prior distribution at a given point.

Parameters:

x (Union[float, np.ndarray]) – The point(s) at which to evaluate the first derivative. The length of x should match the total number of parameters in the joint distribution.

Returns:

A tuple containing the log-probability density and its first derivative at x.

Return type:

Tuple[float, np.ndarray]

logpdf(x: float | numpy.ndarray) float[source]#

Evaluates the joint log-prior distribution at a given point.

Parameters:

x (Union[float, np.ndarray]) – The point(s) at which to evaluate the distribution. The length of x should match the total number of parameters in the joint distribution.

Returns:

The joint log-probability density of the distribution at x.

Return type:

float

_n_parameters = 0[source]#
_priors: list[BasePrior] = [][source]#
class pybop.parameters.priors.Uniform(lower, upper, random_state=None)[source]#

Bases: BasePrior

Represents a uniform distribution over a specified interval.

This class provides methods to calculate the pdf, the log pdf, and to generate random variates from the distribution.

Parameters:
  • lower (float) – The lower bound of the distribution.

  • upper (float) – The upper bound of the distribution.

_logpdfS1(x)[source]#

Evaluates the first derivative of the log uniform distribution at x.

Parameters:

x (float) – The point(s) at which to evaluate the first derivative.

Returns:

The value(s) of the first derivative at x.

Return type:

float

_n_parameters = 1[source]#
loc[source]#
lower[source]#
property mean[source]#

Returns the mean of the distribution.

name = 'Uniform'[source]#
prior[source]#
scale[source]#
property sigma[source]#

Returns the standard deviation of the distribution.

upper[source]#