pybop.parameters.distributions#
Classes#
A base class for defining parameter 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 distribution composed of multiple distributions. |
|
Represents a uniform distribution over a specified interval. |
Module Contents#
- class pybop.parameters.distributions.Distribution(distribution: scipy.stats.distributions.rv_frozen | None = None)[source]#
A base class for defining parameter distributions.
This class provides a foundation for implementing various 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.distributions.rv_frozen
- _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
- mean()[source]#
Get the mean of the distribution.
- Returns:
The mean of the distribution.
- 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.
- std()[source]#
Get the standard deviation of the distribution.
- Returns:
The standard deviation of the distribution.
- Return type:
float
- distribution = None#
- class pybop.parameters.distributions.Exponential(scale: float, loc: float = 0)[source]#
Bases:
DistributionRepresents 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.
- _dlogpdf_dx(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#
- loc = 0#
- name = 'Exponential'#
- scale#
- class pybop.parameters.distributions.Gaussian(mean, sigma, truncated_at: list[float] = None)[source]#
Bases:
DistributionRepresents 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.
- _dlogpdf_dx(x)[source]#
Evaluates the first derivative of the log Gaussian 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#
- loc#
- name = 'Gaussian'#
- scale#
- class pybop.parameters.distributions.JointDistribution(*distributions: Distribution | scipy.stats.distributions.rv_frozen)[source]#
Bases:
DistributionRepresents a joint distribution composed of multiple distributions.
- Parameters:
distributions (Distribution) – One or more distributions to combine into a joint distribution.
- logpdf(x: float | numpy.ndarray) float[source]#
Evaluates the log of the joint 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 log of the joint 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]
- _distributions_list: list[Distribution]#
- _n_parameters = 0#
- class pybop.parameters.distributions.Uniform(lower, upper)[source]#
Bases:
DistributionRepresents 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.
- _dlogpdf_dx(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#
- lower#
- name = 'Uniform'#
- upper#