gemseo.uncertainty.distributions.base_distribution_fitter module#

Fitting a probability distribution to data using a UQ library.

class BaseDistributionFitter(variable, data)[source]#

Bases: Generic[_DistributionT]

Base class to fit a probability distribution from data using a UQ library.

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • variable (str) -- The name of the variable.

  • data (RealArray) -- A data array.

class SelectionCriterion(*values)[source]#

Bases: StrEnum

The selection criteria.

BEST = 'best'#

Select the distribution that best satisfies a fitting criterion

FIRST = 'first'#

Select the first distribution satisfying a fitting criterion.

classmethod select_from_measures(measures, fitting_criterion, level=0.05, selection_criterion=SelectionCriterion.BEST)[source]#

Select the best probability distribution according to a fitting criterion.

Parameters:
  • measures (MutableSequence[MeasureType]) -- The goodness-of-fit measures.

  • fitting_criterion (FittingCriterion) -- The name of the fitting criterion to measure the goodness-of-fit of the probability distribution.

  • level (float) --

    A test level, i.e. the risk of committing a Type 1 error, that is an incorrect rejection of a true null hypothesis, for criteria based on test hypothesis.

    By default it is set to 0.05.

  • selection_criterion (SelectionCriterion) --

    The name of the selection criterion.

    By default it is set to "best".

Returns:

The index of the best probability distribution according to the fitting criterion and the selection criterion.

Return type:

int

compute_measure(distribution, criterion, level=0.05)[source]#

Measure a goodness-of-fit of a probability distribution fitted to data.

Parameters:
  • distribution (_DistributionT | DistributionName) -- Either a GEMSEO probability distribution fitted to data or the name of a probability distribution in the UQ library.

  • criterion (FittingCriterion) -- The name of the fitting criterion to measure the goodness-of-fit of the probability distribution.

  • level (float) --

    A test level, i.e. the risk of committing a Type 1 error, that is an incorrect rejection of a true null hypothesis, for criteria based on test hypothesis.

    By default it is set to 0.05.

Returns:

The goodness-of-fit of the probability distribution fitted to data.

Return type:

MeasureType

abstractmethod fit(distribution)[source]#

Fit a probability distribution to the data.

Parameters:

distribution (DistributionName) -- The name of a probability distribution in the UQ library.

Returns:

The probability distribution fitted to the data.

Return type:

_DistributionT

select(distributions, fitting_criterion, level=0.05, selection_criterion=SelectionCriterion.BEST)[source]#

Select the best probability distribution according to a fitting criterion.

Parameters:
  • distributions (MutableSequence[_DistributionT | DistributionName]) -- A collection of GEMSEO probability distributions fitted to data or names of probability distributions in the UQ library.

  • fitting_criterion (FittingCriterion) -- The name of the fitting criterion to measure the goodness-of-fit of the probability distribution.

  • level (float) --

    A test level, i.e. the risk of committing a Type 1 error, that is an incorrect rejection of a true null hypothesis, for criteria based on test hypothesis.

    By default it is set to 0.05.

  • selection_criterion (SelectionCriterion) --

    The name of the selection criterion.

    By default it is set to "best".

Returns:

The best probability distribution according to the fitting criterion and the selection criterion.

Return type:

_DistributionT

DistributionName: ClassVar[StrEnum]#

The names of the probability distributions in the UQ library.

FittingCriterion: ClassVar[StrEnum]#

The names of the fitting criteria.

SignificanceTest: ClassVar[StrEnum]#

The names of the fitting criteria that are statistical significance tests.

property available_criteria: list[str]#

The available fitting criteria.

property available_distributions: list[str]#

The available probability distributions.

property available_significance_tests: list[str]#

The significance tests.

property data: RealArray#

The data array.

default_fitting_criterion: ClassVar[BaseDistributionFitter.FittingCriterion]#

The names of the default fitting criterion.

variable: str#

The name of the variable.