QuantileConfidence¶
- class QuantileConfidence(*args)¶
Estimate confidence intervals of a quantile.
Refer to Exact quantile confidence interval based on order statistics.
Warning
This class is experimental and likely to be modified in future releases. To use it, import the
openturns.experimentalsubmodule.- Parameters:
- alphafloat
Quantile level
- betafloat, optional
Confidence level. Default value is 0.95
Methods
Evaluate asymptotic bilateral bounds of a quantile.
Evaluate the asymptotic bilateral rank of a quantile.
Evaluate a bilateral confidence interval of a quantile.
Evaluate a bilateral confidence interval of a quantile.
Evaluate the minimum size of the sample for the bilateral min - max confidence interval.
computeBilateralRank(size)Evaluate the ranks of a quantile bilateral bound.
Evaluate an unilateral confidence interval of a quantile.
Evaluate an unilateral confidence interval of a quantile.
computeUnilateralMinimumSampleSize([rank, tail])Evaluate the minimum sample size for the unilateral confidence interval.
computeUnilateralRank(size[, tail])Evaluate the rank of a quantile lower bound.
getAlpha()Quantile level accessor.
getBeta()Confidence level accessor.
Accessor to the object's name.
getName()Accessor to the object's name.
hasName()Test if the object is named.
setAlpha(alpha)Quantile level accessor.
setBeta(beta)Confidence level accessor.
setName(name)Accessor to the object's name.
Notes
This class estimates bounds of the quantile of level
of the random variable
with a confidence greater than
using order statistics.
Let
be the unknown quantile of level
of the random variable
of dimension 1. Let
be a sample of independent and identically distributed variables according to
.
The bounds of the interval are computed from order statistics that we now introduce. Let
be the
-th order statistics of
for
. For example,
and
.
We have:
Care: Python enumeration begins at 0 so that the mathematical
order statistics of the theoretical file Exact quantile confidence interval based on order statistics where
corresponds to the order statistics
given by the library with this class QuantileConfidence.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> sample = ot.Gumbel().getSample(100) >>> algo = otexp.QuantileConfidence(alpha, beta) >>> ci = algo.computeUnilateralConfidenceInterval(sample)
- __init__(*args)¶
- computeAsymptoticBilateralConfidenceInterval(sample)¶
Evaluate asymptotic bilateral bounds of a quantile.
The asymptotic bounds are given by the order statistics:
so that:
where the ranks
are given by
computeAsymptoticBilateralRank().- Parameters:
- sample2-d sequence of float
Sample of the variable
- Returns:
- ci
Interval Quantile confidence interval
- ci
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> sample = ot.Gumbel().getSample(60) >>> ci = algo.computeAsymptoticBilateralConfidenceInterval(sample)
- computeAsymptoticBilateralRank(size)¶
Evaluate the asymptotic bilateral rank of a quantile.
This method computes two integers
such that:
In other words, the interval
is an asymptotic confidence interval for
with asymptotic confidence
. The asymptotic bilateral ranks
are estimated from:
with
the standard Gaussian quantile of order
, see [delmas2006] proposition 12.2.13 page 257.
- Parameters:
- sizeint
Sample size
- Returns:
- ranks
Indicesof size 2 Pair of lower and upper ranks
with
.
- ranks
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> k1, k2 = algo.computeAsymptoticBilateralRank(100) >>> print(k1, k2) 0 8
- computeBilateralConfidenceInterval(sample)¶
Evaluate a bilateral confidence interval of a quantile.
The confidence interval for the quantile of level
is given by the order statistics:
where
are the ranks with
defined by:
The ranks
are given by
computeBilateralRank().The statistics values are evaluated from the given sample.
- Parameters:
- sample2-d sequence of float
Sample of the variable
.
- Returns:
- ci
Interval Quantile confidence interval.
- ci
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> sample = ot.Gumbel().getSample(60) >>> ci = algo.computeBilateralConfidenceInterval(sample)
- computeBilateralConfidenceIntervalWithCoverage(sample)¶
Evaluate a bilateral confidence interval of a quantile.
Refer to
computeBilateralConfidenceInterval()- Parameters:
- sample2-d sequence of float
Sample of the variable
.
- Returns:
- ci
Interval Quantile confidence interval.
- coveragefloat
The coverage is the value of
. The coverage is guaranteed to be greater or equal to
.
- ci
Notes
Refer to
computeBilateralConfidenceInterval(). In addition to the confidence interval, the method returns the supremum offor the confidence interval.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> sample = ot.Gumbel().getSample(60) >>> ci, coverage = algo.computeBilateralConfidenceIntervalWithCoverage(sample)
- computeBilateralMinimumSampleSize()¶
Evaluate the minimum size of the sample for the bilateral min - max confidence interval.
The method determines the smallest sample size
so that:
In other words, the interval
is a bilateral confidence interval for the quantile
with confidence
, where
and
.
The statistics values are evaluated from the sample.
See Exact quantile confidence interval based on order statistics to get the conditions of the existence of a solution and the solution.
- Returns:
- sizeint
Minimum sample size
.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> size = algo.computeBilateralMinimumSampleSize() >>> print(size) 59
- computeBilateralRank(size)¶
Evaluate the ranks of a quantile bilateral bound.
The ranks
with
are defined by:
In other words, the interval
is a bilateral confidence interval for the quantile
with confidence
.
See Exact quantile confidence interval based on order statistics to get the conditions of the existence of a solution and the solution.
- Parameters:
- sizeint
Sample size
.
- Returns:
- ranks
Indicesof size 2 Pair of lower and upper ranks
.
- ranks
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> k1, k2 = algo.computeBilateralRank(100) >>> print((k1, k2)) (1, 10)
- computeUnilateralConfidenceInterval(sample, tail=False)¶
Evaluate an unilateral confidence interval of a quantile.
The lower bounded confidence interval is given by the order statistics:
where
is the largest rank with
so that:
The upper bounded confidence interval :
where
is the smallest rank with
so that:
The lower or upper ranks
and
are given by
computeUnilateralRank().The statistics values are evaluated from the given sample.
- Parameters:
- sample2-d sequence of float
Quantile level
- lower_boundedbool, optional
True indicates the interval is bounded by a lower value.
False indicates the interval is bounded by an upper value.
Default value is False.
- Returns:
- ci
Interval Quantile confidence interval.
- ci
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> sample = ot.Gumbel().getSample(100) >>> ci = algo.computeUnilateralConfidenceInterval(sample)
- computeUnilateralConfidenceIntervalWithCoverage(sample, tail=False)¶
Evaluate an unilateral confidence interval of a quantile.
Refer to
computeUnilateralConfidenceInterval()- Parameters:
- sample2-d sequence of float
Quantile level
- lower_boundedbool, optional
True indicates the interval is bounded by a lower value. False indicates the interval is bounded by an upper value. Default value is False.
- Returns:
- ci
Interval Quantile confidence interval.
- coveragefloat
If lower_bounded is True, then the coverage is the value of
. Otherwise, the coverage is the value of
. In both cases, the coverage is guaranteed to be greater or equal to
.
- ci
Notes
Refer to
computeUnilateralConfidenceInterval(). In addition to the confidence interval, the method returns the supremum offor the confidence interval.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> sample = ot.Gumbel().getSample(100) >>> ci, coverage = algo.computeUnilateralConfidenceIntervalWithCoverage(sample)
- computeUnilateralMinimumSampleSize(rank=0, tail=False)¶
Evaluate the minimum sample size for the unilateral confidence interval.
The rank
is specified. The method computes the smallest sample size
so that:
in the case of a lower bound of the quantile of order
, and:
in the case of an upper bound.
In other words, the interval
or
is a unilateral confidence interval for the quantile
with confidence
. The statistics values are evaluated from the sample.
See Exact quantile confidence interval based on order statistics to get the conditions of the existence of a solution and the solution.
- Parameters:
- kint, optional,
Rank of the quantile.
Default value is 0.
- lower_boundedbool, optional
True indicates the interval is bounded by a lower value.
False indicates the interval is bounded by an upper value.
Default value is False.
- kint, optional,
- Returns:
- sizeint
Minimum sample size
.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> size = algo.computeUnilateralMinimumSampleSize(0) >>> print(size) 59
- computeUnilateralRank(size, tail=False)¶
Evaluate the rank of a quantile lower bound.
The lower rank
is the largest rank
with
such that:
In other words, the interval
is a unilateral confidence interval for the quantile
with confidence
.
The upper rank
is the smallest rank
with
such that:
In other words, the interval
is a unilateral confidence interval for the quantile
with confidence
.
See Exact quantile confidence interval based on order statistics to get the conditions of the existence of a solution and the solution for each case.
- Parameters:
- sizeint
Sample size
- lower_boundedbool, optional
True indicates the interval is bounded by a lower value.
False indicates the interval is bounded by an upper value.
Default value is False.
- Returns:
- rankint
Rank
.
Examples
>>> import openturns as ot >>> import openturns.experimental as otexp >>> alpha = 0.05 >>> beta = 0.95 >>> algo = otexp.QuantileConfidence(alpha, beta) >>> rank = algo.computeUnilateralRank(100) >>> print(rank) 9
- getAlpha()¶
Quantile level accessor.
- Returns:
- alphafloat
Quantile level
- getBeta()¶
Confidence level accessor.
- Returns:
- betafloat
Confidence level
- getClassName()¶
Accessor to the object’s name.
- Returns:
- class_namestr
The object class name (object.__class__.__name__).
- getName()¶
Accessor to the object’s name.
- Returns:
- namestr
The name of the object.
- hasName()¶
Test if the object is named.
- Returns:
- hasNamebool
True if the name is not empty.
- setAlpha(alpha)¶
Quantile level accessor.
- Parameters:
- alphafloat
Quantile level
- setBeta(beta)¶
Confidence level accessor.
- Parameters:
- betafloat
Confidence level
- setName(name)¶
Accessor to the object’s name.
- Parameters:
- namestr
The name of the object.
Examples using the class¶
Estimate quantile confidence intervals from chemical process data
OpenTURNS