sp_dist module¶
Distributions based on scipy¶
Overview¶
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.
Construction¶
The SPDistribution
of a given uncertain variable is built
from mandatory arguments:
a variable name,
a distribution name recognized by OpenTURNS,
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
).
Classical distributions¶
This module also implements a deliberately limited selection
of classical probability distributions
in a user-friendly way: SPExponentialDistribution
,
SPNormalDistribution
, SPTriangularDistribution
,
and SPUniformDistribution
. More precisely,
the argument whose nature is a dictionary of keyword parameters
is replaced with several user-defined keyword arguments.
In this way, the use writes SPUniformDistribution('x', -1., 3.)
or SPUniformDistribution('x', lower=-1., upper=3.)
instead of SPDistribution('x', 'Normal', (-1., 3.))
.
Furthermore, these classes inheriting from SPDistribution
are documented in such a way that a newbie could easily apprehend them.
-
class
gemseo.uncertainty.distributions.sp_dist.
SPDistribution
(variable, distribution, parameters, dimension=1, standard_parameters=None)[source]¶ Bases:
gemseo.uncertainty.distributions.distribution.Distribution
The SPDistribution inherits from Distribution. It relies on the probabilistic modeling features of the scipy library.
Constructor
- Parameters
variable (str) – variable name.
distribution (str) – distribution name.
parameters (tuple) – distribution parameters.
dimension (int) – variable dimension.
standard_parameters (dict) – standard parameters.
-
COMPOSED_DISTRIBUTION
¶ alias of
gemseo.uncertainty.distributions.sp_cdist.SPComposedDistribution
-
cdf
(vector)[source]¶ Evaluate the cumulative density function of the random variable marginals for a given instance.
- Parameters
vector (array) – instance of the random variable.
- Returns
cdf values
- Return type
array
-
get_sample
(n_samples=1)[source]¶ Get several samples.
- Parameters
n_samples (int) – number of samples.
- Returns
samples
- Return type
array
-
inverse_cdf
(vector)[source]¶ Evaluate the inverse of the cumulative density function of the random variable marginals for a given unit vector .
- Parameters
vector (array) – vector of values comprised between 0 and 1 with same dimension as the random variable.
- Returns
inverse cdf values
- Return type
array
-
property
mean
¶ Get the mean of the random variable.
- Returns
mean of the random variable.
- Return type
array
-
property
standard_deviation
¶ Get the standard deviation of the random variable.
- Returns
standard deviation of the random variable.
- Return type
array
-
class
gemseo.uncertainty.distributions.sp_dist.
SPExponentialDistribution
(variable, rate=1.0, loc=0.0, dimension=1)[source]¶ Bases:
gemseo.uncertainty.distributions.sp_dist.SPDistribution
Create a exponential distribution.
Constructor.
- Parameters
variable (str) – variable name.
rate (float) – rate parameter.
loc (float) – location parameter.
dimension (int) – dimension.
-
class
gemseo.uncertainty.distributions.sp_dist.
SPNormalDistribution
(variable, mu=0.0, sigma=1.0, dimension=1)[source]¶ Bases:
gemseo.uncertainty.distributions.sp_dist.SPDistribution
Create a normal distribution.
Constructor.
- Parameters
variable (str) – variable name.
mu (float) – mean.
sigma (float) – standard deviation.
dimension (int) – dimension.
-
class
gemseo.uncertainty.distributions.sp_dist.
SPTriangularDistribution
(variable, lower=0.0, mode=0.5, upper=1.0, dimension=1)[source]¶ Bases:
gemseo.uncertainty.distributions.sp_dist.SPDistribution
Create a triangular distribution.
Constructor.
- Parameters
variable (str) – variable name.
lower (float) – lower bound.
mode (float) – mode.
upper (float) – upper bound.
dimension (int) – dimension.
-
class
gemseo.uncertainty.distributions.sp_dist.
SPUniformDistribution
(variable, lower=0.0, upper=1.0, dimension=1)[source]¶ Bases:
gemseo.uncertainty.distributions.sp_dist.SPDistribution
Create a uniform distribution.
Constructor.
- Parameters
variable (str) – variable name.
lower (float) – lower bound.
upper (float) – upper bound.
dimension (int) – dimension.