distribution module¶
Class to create a probability distribution from the SciPy library.
The SPDistribution
class is a concrete class
inheriting from Distribution
which is an abstract one.
SP stands for scipy
which is the library it relies on.
The SPDistribution
of a given uncertain variable is built
from mandatory arguments:
a variable name,
a distribution name recognized by SciPy,
a set of parameters provided as a dictionary of keyword arguments named as the arguments of the scipy constructor of this distribution.
Warning
The distribution parameters must be provided according to the signature of the scipy classes. Access the scipy documentation.
The constructor has also optional arguments:
a variable dimension (default: 1),
a standard representation of these parameters (default: use
parameters
).
- class gemseo.uncertainty.distributions.scipy.distribution.SPDistribution(variable, interfaced_distribution, parameters, dimension=1, standard_parameters=None)[source]
Bases:
Distribution
SciPy probability distribution.
Create a probability distribution for an uncertain variable from its dimension and distribution names and properties.
See also
SPExponentialDistribution
SPNormalDistribution
SPTriangularDistribution
SPUniformDistribution
Example
>>> from gemseo.uncertainty.distributions.scipy.distribution import ( ... SPDistribution ... ) >>> distribution = SPDistribution('x', 'expon', {'loc': 3, 'scale': 1/2.}) >>> print(distribution) expon(loc=3, scale=0.5)
- Parameters:
variable (str) – The name of the random variable.
interfaced_distribution (str) – The name of the probability distribution, typically the name of a class wrapped from an external library, such as
"norm"
for SciPy.parameters (ParametersType) – The parameters of the probability distribution.
dimension (int) –
The dimension of the random variable.
By default it is set to 1.
standard_parameters (StandardParametersType | None) – The standard representation of the parameters of the probability distribution.
- compute_cdf(vector)[source]
Evaluate the cumulative density function (CDF).
Evaluate the CDF of the components of the random variable for a given realization of this random variable.
- compute_inverse_cdf(vector)[source]
Evaluate the inverse of the cumulative density function (ICDF).
- compute_samples(n_samples=1)[source]
Sample the random variable.
- dimension: int
The number of dimensions of the random variable.
- distribution: type
The probability distribution of the random variable.
- distribution_name: str
The name of the probability distribution.
- math_lower_bound: ndarray
The mathematical lower bound of the random variable.
- math_upper_bound: ndarray
The mathematical upper bound of the random variable.
- property mean: ndarray
The analytical mean of the random variable.
- num_lower_bound: ndarray
The numerical lower bound of the random variable.
- num_upper_bound: ndarray
The numerical upper bound of the random variable.
- property standard_deviation: ndarray
The analytical standard deviation of the random variable.
- standard_parameters: dict[str, str] | None
The standard representation of the parameters of the distribution, used for its string representation.
- transformation: str
The transformation applied to the random variable, e.g. ‘sin(x)’.
- variable_name: str
The name of the random variable.