pybop.parameters.priors#
Classes#
A base class for defining prior distributions. |
|
Represents an exponential distribution with a specified scale parameter. |
|
Represents a Gaussian (normal) distribution with a given mean and standard deviation. |
|
Represents a joint prior distribution composed of multiple prior distributions. |
|
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.
- distribution#
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
- _dlogpdf_dx(x)[source]#
Evaluates the first derivative of the log distribution at x.
Overwrite this function in a subclass to improve upon this generic finite difference approximation.
- 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.
- class pybop.parameters.priors.Exponential(loc=0, scale=1, random_state=None)[source]#
Bases:
BasePriorRepresents 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.
- class pybop.parameters.priors.Gaussian(mean, sigma, random_state=None)[source]#
Bases:
BasePriorRepresents 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.
- class pybop.parameters.priors.JointPrior(*priors: BasePrior)[source]#
Bases:
BasePriorRepresents a joint prior distribution composed of multiple prior distributions.
- Parameters:
priors (BasePrior) – One or more prior distributions to combine into a joint distribution.
- logpdf(x: float | numpy.ndarray) float[source]#
Evaluates the joint log-prior distribution at a given point.
- Parameters:
x (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
- 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 (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]
- class pybop.parameters.priors.Uniform(lower, upper, random_state=None)[source]#
Bases:
BasePriorRepresents 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.