gemseo.uncertainty.distributions.scipy.distribution module#

The interface to SciPy-based probability distributions.

class SPDistribution(interfaced_distribution='uniform', parameters=mappingproxy({}), standard_parameters=mappingproxy({}))[source]#

Bases: BaseDistribution[float, Mapping[str, Any], rv_continuous_frozen], ScalarDistributionMixin

A SciPy-based probability distribution.

Warning

The distribution parameters must be provided according to the signature of the scipy classes. Access the scipy documentation.

Examples

>>> from gemseo.uncertainty.distributions.scipy.distribution import (
...     SPDistribution,
... )
>>> distribution = SPDistribution("expon", {"loc": 3, "scale": 1 / 2.0})
>>> print(distribution)
expon(loc=3, scale=0.5)

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • interfaced_distribution (str) --

    The name of the probability distribution, typically the name of a class wrapped from an external library, such as "Normal" for OpenTURNS or "norm" for SciPy.

    By default it is set to "uniform".

  • parameters (StrKeyMapping) --

    The parameters of the probability distribution.

    By default it is set to {}.

  • standard_parameters (StandardParametersType) --

    The parameters of the probability distribution used for string representation only (use parameters for computation). If empty, use parameters instead. For instance, let us consider the interfaced SciPy distribution "uniform". Then, the string representation of SPDistribution("uniform", parameters, 1, {"min": 1, "max": 3}) with parameters={"loc": 1, "scale": 2} is "uniform(max=3, min=1)" while the string representation of SPDistribution("uniform", parameters) is "uniform(loc=1, scale=2)".

    By default it is set to {}.

JOINT_DISTRIBUTION_CLASS#

alias of SPJointDistribution

compute_cdf(value)[source]#

Evaluate the cumulative density function (CDF).

Parameters:

value (float) -- The value of the random variable for which to evaluate the CDF.

Returns:

The value of the CDF.

Return type:

float

compute_inverse_cdf(value)[source]#

Evaluate the inverse cumulative density function (ICDF).

Parameters:

value (float) -- The probability for which to evaluate the ICDF.

Returns:

The value of the ICDF.

Return type:

float

compute_samples(n_samples=1, random_state=None)[source]#

Sample the random variable.

Parameters:
  • n_samples (int) --

    The number of samples.

    By default it is set to 1.

  • random_state (None | int | Generator | RandomState) -- The SciPy random state.

Returns:

The samples of the random variable.

Return type:

RealArray

property mean: float#

The expectation of the random variable.

property standard_deviation: float#

The standard deviation of the random variable.