pybop.parameters.multivariate_distributions#
Classes#
A base class for defining multivariate parameter distributions. |
|
Represents a univariate marginal distribution of a pybop.BaseMultivariateDistribution. |
|
Represents a multivariate Gaussian (normal) distribution with a |
|
Represents a multivariate log-normal distribution with a |
|
Represents a "freeform" distribution, i.e., one that is defined from |
|
Represents a multivariate uniform distribution. |
Module Contents#
- class pybop.parameters.multivariate_distributions.BaseMultivariateDistribution(distribution: scipy.stats.distributions.rv_frozen, properties: dict | None = None, n_parameters: int = 1)[source]#
Bases:
pybop.parameters.distributions.DistributionA base class for defining multivariate parameter distributions.
This class extends
pybop.Distributionwith methods that reduce the output of a multivariate distribution to its individual dimensions.Note that, unlike in
pybop.Distribution, distribution attributes are stored in a dictionary, as multivariate distributions in SciPy do not follow the loc/scale convention.- distribution#
The underlying continuous random variable distribution.
- Type:
scipy.stats.rv_continuous
- properties#
A dictionary with distribution keyword argument names as string keys and their values as float values.
- Type:
dict
- 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
- cdf_marginal(x, position: int)[source]#
Takes the marginal cumulative distribution function (CDF) at x.
- Parameters:
x (numpy.ndarray) – The point(s) at which to evaluate the CDF.
position (int) – The dimension to which to reduce the CDF to.
- Returns:
The marginal cumulative distribution function value at x.
- Return type:
float
- check_consistent_transformation(transform: pybop.transformation.base_transformation.Transformation) None[source]#
Raise an error if a composed transformation contains incompatible types of transformation.
- get_transformed_distribution(transform: pybop.transformation.base_transformation.Transformation) pybop.parameters.distributions.BaseDistribution | None[source]#
Get the transformed distribution in the search space.
- logpdf(x)[source]#
Calculates the logarithm of the probability density function of the distribution at x.
- abstractmethod marginal(position: int)[source]#
Return univariate marginal distribution of parameter with index ‘position’.
- rvs(size: int = 1, random_state: int | None = None)[source]#
Generates random variates from the distribution.
- support() numpy.ndarray[source]#
Return the support as a numpy array of dimensions (2, n_parameters).
- icdf = None#
Multivariate distributions have no invertible CDF.
- class pybop.parameters.multivariate_distributions.MarginalDistribution(parent_distribution: BaseMultivariateDistribution, position: int)[source]#
Bases:
pybop.parameters.distributions.DistributionRepresents a univariate marginal distribution of a pybop.BaseMultivariateDistribution. Relies on the “marginal” method of the multivariate distribution.
Sub-class of pybop.Distribution with the additional properties “parent_distribution” and “position”
- Parameters:
parent_distribution (pybop.BaseMultivariateDistribution) – A multivariate distribution
position (int) – position of the parameter for which to create the marginal distribution
- get_transformed_distribution(transform: pybop.transformation.base_transformation.Transformation) pybop.parameters.distributions.BaseDistribution | None[source]#
Get the transformed distribution in the search space, by first transforming the parent distribution and then fetching the marginal distribution.
- _position#
- parent_distribution#
- property position: int#
- class pybop.parameters.multivariate_distributions.MultivariateGaussian(mean: numpy.ndarray, covariance: numpy.ndarray)[source]#
Bases:
BaseMultivariateDistributionRepresents a multivariate Gaussian (normal) distribution with a given mean and covariance.
- Parameters:
mean (numpy.ndarray) – The mean (µ) of the multivariate Gaussian distribution.
covariance (numpy.ndarray) – The covariance matrix (Σ) of the multivariate Gaussian distribution. Note that what is called σ in 1D would be the square root of Σ here.
- _transform(transform: pybop.transformation.base_transformation.Transformation) pybop.parameters.distributions.BaseDistribution | None[source]#
Get the transformed distribution in the search space.
- class pybop.parameters.multivariate_distributions.MultivariateLogNormal(mean_log_x, covariance_log_x)[source]#
Bases:
BaseMultivariateDistributionRepresents a multivariate log-normal distribution with a given mean and covariance of the normally distributed log(x).
- Parameters:
mean_log_x (numpy.ndarray) – The mean (µ) of the multivariate Gaussian distribution of log(x).
covariance_log_x (numpy.ndarray) – The covariance matrix (Σ) of the multivariate Gaussian distribution of log(x). Note that what is called σ in 1D would be the square root of Σ here.
- _get_properties()[source]#
Method to compute the mean and covariance of x given the mean and covariance of log(x).
- _transform(transform: pybop.transformation.base_transformation.Transformation) pybop.parameters.distributions.BaseDistribution | None[source]#
Get the transformed distribution in the search space.
- 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
- logpdf(x)[source]#
Calculates the logarithm of the probability density function of the distribution at x.
- marginal(position: int)[source]#
Return univariate marginal distribution of parameter with index ‘position’.
- rvs(size: int = 1, random_state: int | None = None)[source]#
Generates random variates from the distribution.
- support() numpy.ndarray[source]#
Return the support as a numpy array of dimensions (2, n_parameters).
- distribution_log_x#
- properties#
- properties_log_x#
- class pybop.parameters.multivariate_distributions.MultivariateNonparametric(samples: numpy.ndarray)[source]#
Bases:
BaseMultivariateDistributionRepresents a “freeform” distribution, i.e., one that is defined from a random sampling and a kernel density estimate on that sampling.
- Parameters:
samples (numpy.ndarray) – The random variates to base the distribution on.
- marginal(position: int)[source]#
Return univariate marginal distribution of parameter with index ‘position’.
- class pybop.parameters.multivariate_distributions.MultivariateUniform(bounds: numpy.ndarray)[source]#
Bases:
BaseMultivariateDistributionRepresents a multivariate uniform distribution.
- Parameters:
bounds (numpy.ndarray) – The lower and upper bounds for the uniform distribution as an array with dimensions (2, n_parameters).
- _transform(transform: pybop.transformation.base_transformation.Transformation) pybop.parameters.distributions.BaseDistribution | None[source]#
Get the transformed distribution in the search space.