composed module¶
Class to create a joint probability distribution from the SciPy library.
The SPComposedDistribution
class is a concrete class
inheriting from ComposedDistribution
which is an abstract one.
SP stands for scipy which is the library it relies on.
This class inherits from SPDistribution
.
It builds a composed probability distribution
related to given random variables from a list of SPDistribution
objects
implementing the probability distributions of these variables
based on the SciPy library 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.
- class gemseo.uncertainty.distributions.scipy.composed.SPComposedDistribution(distributions, copula='independent_copula')[source]¶
Bases:
gemseo.uncertainty.distributions.composed.ComposedDistribution
Scipy composed distribution.
- Parameters
distributions (list(SPDistribution)) – The distributions.
copula (str, optional) –
A name of copula.
By default it is set to independent_copula.
- Return type
None
- 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.
- Parameters
vector (Iterable[float]) – A realization of the random variable.
- Returns
The CDF values of the components of the random variable.
- Return type
- compute_inverse_cdf(vector)[source]¶
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
- 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
- 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 (str | Path | None) –
The path of the file to save the figures. If the extension is missing, use
file_extension
. If None, create a file path fromdirectory_path
,file_name
andfile_extension
.By default it is set to None.
directory_path (str | Path | None) –
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 (str | None) –
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 (str | None) –
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
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 (str | Path | None) –
The path of the file to save the figures. If the extension is missing, use
file_extension
. If None, create a file path fromdirectory_path
,file_name
andfile_extension
.By default it is set to None.
directory_path (str | Path | None) –
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 (str | None) –
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 (str | None) –
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[Figure]
- AVAILABLE_COPULA_MODELS = ['independent_copula']¶
- 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: numpy.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 range: list[numpy.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: numpy.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[numpy.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.