gemseo / uncertainty / distributions / openturns

uniform module¶

Class to create an uniform distribution from the OpenTURNS library.

This class inherits from OTDistribution.

Classes:

 OTUniformDistribution(variable[, minimum, ...]) Create an uniform distribution.
class gemseo.uncertainty.distributions.openturns.uniform.OTUniformDistribution(variable, minimum=0.0, maximum=1.0, dimension=1, transformation=None, lower_bound=None, upper_bound=None, threshold=0.5)[source]

Create an uniform distribution.

Example

>>> from gemseo.uncertainty.distributions.openturns.uniform import (
...     OTUniformDistribution
>>> )
>>> distribution = OTUniformDistribution('x', -1, 1)
>>> print(distribution)
Uniform(lower=-1, upper=1)

Parameters
• variable (str) – The name of the uniform random variable.

• minimum (float) –

The minimum of the uniform random variable.

By default it is set to 0.0.

• maximum (float) –

The maximum of the uniform random variable.

By default it is set to 1.0.

• dimension (int) –

The dimension of the uniform random variable.

By default it is set to 1.

• transformation (Optional[str]) –

A transformation applied to the random variable, e.g. ‘sin(x)’. If None, no transformation.

By default it is set to None.

• lower_bound (Optional[float]) –

A lower bound to truncate the distribution. If None, no lower truncation.

By default it is set to None.

• upper_bound (Optional[float]) –

An upper bound to truncate the distribution. If None, no upper truncation.

By default it is set to None.

• threshold (float) –

A threshold in [0,1].

By default it is set to 0.5.

Return type

None

Methods:

 compute_cdf(vector) Evaluate the cumulative density function (CDF). compute_inverse_cdf(vector) Evaluate the inverse of the cumulative density function (ICDF). compute_samples([n_samples]) Sample the random variable. plot([index, show, save, file_path, ...]) Plot both probability and cumulative density functions for a given component. plot_all([show, save, file_path, ...]) Plot both probability and cumulative density functions for all components.

Attributes:

 mean The analytical mean of the random variable. range The numerical range. standard_deviation The analytical standard deviation of the random variable. support The mathematical support.
compute_cdf(vector)

Evaluate the cumulative density function (CDF).

Evaluate the CDF of the components of the random variable for a given realization of this random variable.

Parameters

vector (Iterable[float]) – A realization of the random variable.

Returns

The CDF values of the components of the random variable.

Return type

numpy.ndarray

compute_inverse_cdf(vector)

Evaluate the inverse of the cumulative density function (ICDF).

Parameters

vector (Iterable[float]) – A vector of values comprised between 0 and 1 whose length is equal to the dimension of the random variable.

Returns

The ICDF values of the components of the random variable.

Return type

numpy.ndarray

compute_samples(n_samples=1)

Sample the random variable.

Parameters

n_samples (int) –

The number of samples.

By default it is set to 1.

Returns

The samples of the random variable,

The number of columns is equal to the dimension of the variable and the number of lines is equal to the number of samples.

Return type

numpy.ndarray

property mean

The analytical mean of the random variable.

plot(index=0, show=True, save=False, file_path=None, directory_path=None, file_name=None, file_extension=None)

Plot both probability and cumulative density functions for a given component.

Parameters
• index (int) –

The index of a component of the random variable.

By default it is set to 0.

• save (bool) –

If True, save the figure.

By default it is set to False.

• show (bool) –

If True, display the figure.

By default it is set to True.

• file_path (Optional[Union[str, pathlib.Path]]) –

The path of the file to save the figures. If the extension is missing, use file_extension. If None, create a file path from directory_path, file_name and file_extension.

By default it is set to None.

• directory_path (Optional[Union[str, pathlib.Path]]) –

The path of the directory to save the figures. If None, use the current working directory.

By default it is set to None.

• file_name (Optional[str]) –

The name of the file to save the figures. If None, use a default one generated by the post-processing.

By default it is set to None.

• file_extension (Optional[str]) –

A file extension, e.g. ‘png’, ‘pdf’, ‘svg’, … If None, use a default file extension.

By default it is set to None.

Returns

The figure.

Return type

matplotlib.figure.Figure

plot_all(show=True, save=False, file_path=None, directory_path=None, file_name=None, file_extension=None)

Plot both probability and cumulative density functions for all components.

Parameters
• save (bool) –

If True, save the figure.

By default it is set to False.

• show (bool) –

If True, display the figure.

By default it is set to True.

• file_path (Optional[Union[str, pathlib.Path]]) –

The path of the file to save the figures. If the extension is missing, use file_extension. If None, create a file path from directory_path, file_name and file_extension.

By default it is set to None.

• directory_path (Optional[Union[str, pathlib.Path]]) –

The path of the directory to save the figures. If None, use the current working directory.

By default it is set to None.

• file_name (Optional[str]) –

The name of the file to save the figures. If None, use a default one generated by the post-processing.

By default it is set to None.

• file_extension (Optional[str]) –

A file extension, e.g. ‘png’, ‘pdf’, ‘svg’, … If None, use a default file extension.

By default it is set to None.

Returns

The figures.

Return type

List[matplotlib.figure.Figure]

property range

The numerical range.

The numerical range is the interval defined by the lower and upper bounds numerically reachable by the random variable.

Here, the numerical range of the random variable is defined by one array for each component of the random variable, whose first element is the lower bound of this component while the second one is its upper bound.

property standard_deviation

The analytical standard deviation of the random variable.

property support

The mathematical support.

The mathematical support is the interval defined by the theoretical lower and upper bounds of the random variable.

Here, the mathematical range of the random variable is defined by one array for each component of the random variable, whose first element is the lower bound of this component while the second one is its upper bound.