factory module¶
Module containing a factory to create an instance of Distribution
.
- class gemseo.uncertainty.distributions.factory.DistributionFactory[source]
Bases:
BaseFactory
Factory to build instances of
Distribution
.At initialization, this factory scans the following modules to search for subclasses of this class:
the modules located in
gemseo.uncertainty.distributions
and its sub-packages,the modules referenced in the
GEMSEO_PATH,
the modules referenced in the
PYTHONPATH
and starting withgemseo_
.
Then, it can check if a class is present or return the list of available classes.
Lastly, it can create an instance of a class.
Examples
>>> from gemseo.uncertainty.distributions.factory import DistributionFactory >>> factory = DistributionFactory() >>> factory.is_available("OTNormalDistribution") True >>> factory.available_distributions[-3:] ['SPNormalDistribution', 'SPTriangularDistribution', 'SPUniformDistribution'] >>> distribution = factory.create("OTNormalDistribution", "x") >>> print(distribution) Normal(mu=0.0, sigma=1.0)
- Return type:
- create(distribution_name, variable, **parameters)
Create a marginal probability distribution for a given random variable.
- Parameters:
- Returns:
The marginal probability distribution.
- Raises:
TypeError – If the class cannot be instantiated.
- Return type:
- create_composed_distribution(distributions, copula=None, variable='')[source]
Create a composed probability distribution from marginal ones.
- Parameters:
distributions (Sequence[Distribution]) – The marginal distributions.
copula (Any | None) – A copula distribution defining the dependency structure between random variables; if
None
, consider an independent copula.variable (str) –
The name of the variable, if any; otherwise, concatenate the names of the random variables defined by
distributions
.By default it is set to “”.
- Returns:
The composed probability distribution.
- Return type: