gemseo / uncertainty / distributions / scipy

Hide inherited members

uniform module

The SciPy-based uniform distribution.

class gemseo.uncertainty.distributions.scipy.uniform.SPUniformDistribution(variable='x', minimum=0.0, maximum=1.0, dimension=1)[source]

Bases: SPDistribution

The SciPy-based uniform distribution.

Examples

>>> from gemseo.uncertainty.distributions.scipy.uniform import (
...     SPUniformDistribution,
... )
>>> distribution = SPUniformDistribution("x", -1, 1)
>>> print(distribution)
uniform(lower=-1, upper=1)
Parameters:
  • variable (str) –

    The name of the random variable.

    By default it is set to “x”.

  • 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 random variable. If greater than 1, the probability distribution is applied to all components of the random variable under the hypothesis that these components are stochastically independent. To be removed in a future version; use a ComposedDistribution instead.

    By default it is set to 1.

COMPOSED_DISTRIBUTION_CLASS

alias of SPComposedDistribution

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:

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:

ndarray

compute_samples(n_samples=1, random_state=None)

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,

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:

ndarray

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

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 (str | Path) –

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

    By default it is set to “”.

  • directory_path (str | Path) –

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

    By default it is set to “”.

  • file_name (str) –

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

    By default it is set to “”.

  • file_extension (str) –

    A file extension, e.g. 'png', 'pdf', 'svg', … If empty, use a default file extension.

    By default it is set to “”.

Returns:

The figure.

Return type:

Figure

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

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 (str | Path) –

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

    By default it is set to “”.

  • directory_path (str | Path) –

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

    By default it is set to “”.

  • file_name (str) –

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

    By default it is set to “”.

  • file_extension (str) –

    A file extension, e.g. 'png', 'pdf', 'svg', … If empty, use a default file extension.

    By default it is set to “”.

Returns:

The figures.

Return type:

list[Figure]

DEFAULT_VARIABLE_NAME: Final[str] = 'x'

The default name of the 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.

marginals: list[type]

The marginal distributions of the components of the random variable.

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.

parameters: tuple[Any] | dict[str, Any]

The parameters of the probability distribution.

property range: list[ndarray]

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: 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.

property support: list[ndarray]

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.

transformation: str

The transformation applied to the random variable, e.g. ‘sin(x)’.

variable_name: str

The name of the random variable.