gemseo / uncertainty / distributions

distribution module

The notions of distribution and composed distributions

Overview

The abstract Distribution class implements the concept of probability distribution. It is enriched by concrete classes such as OTDistribution and SPDistribution.

Similarly, the abstract ComposedDistribution class implements the concept of composed probability distribution from a list of probability distributions. It inherits from Distribution.

Construction

The Distribution of a given uncertain variable is built from a recognized distribution name, a variable dimension, a set of parameters and optionally a standard representation of these parameters.

The ComposedDistribution of a list of given uncertain variables is built from a list of Distribution objects implementing the probability distributions of these variables and from a copula name.

Note

A copula is a mathematical function used to define the dependence between random variables from their cumulative density functions. See more.

Capabilities

From a Distribution, we can easily get statistics, such as Distribution.mean, Distribution.standard_deviation, numerical Distribution.range and mathematical Distribution.support, or plot the cumulative and probability density functions, either for a given marginal (Distribution.plot()) or for all marginals (Distribution.plot_all()).

We can also compute the cumulative density function (Distribution.cdf()) for the different marginals of the random variable, as well as the inverse cumulative density function (Distribution.inverse_cdf()).

Lastly, we can get realizations of the random variable by means of the Distribution.get_sample() method.

Note

As ComposedDistribution inherits from Distribution, it has the same capabilities.

class gemseo.uncertainty.distributions.distribution.ComposedDistribution(distributions, copula='independent_copula')[source]

Bases: gemseo.uncertainty.distributions.distribution.Distribution

Composed Distribution.

Constructor.

Parameters
  • distributions (list(Distribution)) – list of distributions.

  • copula (str) – copula name. Default: INDEPENDENT_COPULA.

AVAILABLE_COPULA = ['independent_copula']
COMPOSED = 'Composed'
INDEPENDENT_COPULA = 'independent_copula'
get_sample(n_samples=1)[source]

Get sample.

Parameters

n_samples (int) – number of samples.

Returns

samples

Return type

list(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.distribution.Distribution(variable, distribution, parameters, dimension, standard_parameters=None)[source]

Bases: object

Distribution.

Constructor

Parameters
  • variable (str) – variable name.

  • distribution (str) – distribution name.

  • parameters (tuple or dict) – distribution parameters.

  • dimension (int) – variable dimension.

  • standard_parameters (dict) – standard parameters.

LOC = 'loc'
LOWER = 'lower'
MATHEMATICAL_LOWER_BOUND = 'math_l_b'
MATHEMATICAL_UPPER_BOUND = 'math_u_b'
MODE = 'mode'
MU = 'mu'
NUMERICAL_LOWER_BOUND = 'num_l_b'
NUMERICAL_UPPER_BOUND = 'num_u_b'
RATE = 'rate'
SIGMA = 'sigma'
UPPER = 'upper'
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

plot(index=0, show=True, save=False, prefix=None)[source]

Plot the probability density function and the cumulative density function of the random variable.

Parameters

prefix (str) – If not None, start the filename with a prefix. Default: None.

plot_all(show=True, save=False, prefix=None)[source]

Plot the probability density function and the cumulative density function of the random variable.

Parameters

prefix (str) – If not None, start the filename with a prefix. Default: None.

property range

Get the numerical range for the different components.

Returns

numerical range.

Return type

list(array)

property standard_deviation

Get the standard deviation of the random variable.

Returns

standard deviation of the random variable.

Return type

array

property support

Get the mathematical support for the different components.

Returns

mathematical support.

Return type

list(array)