QuantileConfidence¶
- class QuantileConfidence(*args)¶
Estimate confidence intervals of a quantile.
Refer to Estimation of a quantile bound.
Warning
This class is experimental and likely to be modified in future releases. To use it, import the
openturns.experimental
submodule.- 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 the minimum size of the sample for the bilateral case.
computeBilateralRank
(size)Evaluate the bilateral rank of a quantile.
Evaluate an unilateral confidence interval of a quantile.
computeUnilateralMinimumSampleSize
([rank, tail])Evaluate the minimum sample size for the unilateral case.
computeUnilateralRank
(size[, tail])Evaluate an unilateral rank of a quantile.
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 a given 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
which means that
is the
-th maximum of
for
.
For example,
is the minimum and
is the maximum.
We have:
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
Indices
of 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:
so that:
where the ranks
are given by
computeBilateralRank()
.- 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)
- computeBilateralMinimumSampleSize()¶
Evaluate the minimum size of the sample for the bilateral case.
The minimal bilateral sample size is the smallest integer
such that:
In other words, this is the minimum sample size such that the interval
is a confidence interval of the quantile
with confidence
. The solution of this problem is the minimum value of
such that:
The sample size
is searched inside the bounds given by the inequality:
where
.
- 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 bilateral rank of a quantile.
The bilateral ranks
are the integers minimizing the probability:
where
is the binomial distribution with parameters
and
.
so that:
These ranks exist only if:
- Parameters:
- sizeint
Sample size
- Returns:
- ranks
Indices
of size 2 Pair of lower and upper ranks
such that
.
- 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 tail confidence interval is given by the order statistics:
so that:
and the upper tail confidence interval is given by the order statistics:
so that:
where the lower or upper ranks
are given by
computeUnilateralRank()
.- Parameters:
- sample2-d sequence of float
Quantile level
- tailbool, 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)
- computeUnilateralMinimumSampleSize(rank=0, tail=False)¶
Evaluate the minimum sample size for the unilateral case.
For the lower bound the minimal unilateral sample size is the smallest integer
such that:
For the upper bound the minimal unilateral sample size is the smallest integer
such that:
In the general case the minimum size of the sample is the smallest
such that:
where
is the cumulative distribution function of the Binomial distribution with parameters
and
.
When the rank
is zero the solution is analytical.
For the lower bound the minimum sample size is the integer that satisfies:
which is given by:
And for the upper bound the minimum sample size is the integer that satisfies:
which is given by:
- Parameters:
- rankint, optional
Rank of the quantile. Default value is 0.
- tailbool, 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:
- 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 an unilateral rank of a quantile.
The lower tail rank
is the largest integer
such that:
In other words, the interval
is a unilateral confidence interval for the quantile
with confidence
.
It is given by:
where
is the complementary quantile function of the binomial distribution with parameters
and
.
The problem has a solution only if:
The upper tail rank
is the smallest integer
such that:
In other words, the interval
is a unilateral confidence interval for the quantile
with confidence
. The solution is:
where
is the quantile function of the cumulative distribution function of the binomial distribution with parameters
and
. The problem has a solution only if:
- Parameters:
- sizeint
Sample size
- tailbool, 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.