icdf#
- Mixture.icdf(p, /, *, method=None)[source]#
Inverse of the cumulative distribution function.
The inverse of the cumulative distribution function (“inverse CDF”), denoted \(F^{-1}(p)\), is the argument \(x\) for which the cumulative distribution function \(F(x)\) evaluates to \(p\).
\[F^{-1}(p) = x \quad \text{s.t.} \quad F(x) = p\]icdf
accepts p for \(p \in [0, 1]\).- Parameters:
- parray_like
The argument of the inverse CDF.
- method{None, ‘formula’, ‘complement’, ‘inversion’}
The strategy used to evaluate the inverse CDF. By default (
None
), the infrastructure chooses between the following options, listed in order of precedence.'formula'
: use a formula for the inverse CDF itself'complement'
: evaluate the inverse CCDF at the complement of p'inversion'
: solve numerically for the argument at which the CDF is equal to p
Not all method options are available for all distributions. If the selected method is not available, a
NotImplementedError
will be raised.
- Returns:
- outarray
The inverse CDF evaluated at the provided argument.
Notes
Suppose a continuous probability distribution has support \([l, r]\). The inverse CDF returns its minimum value of \(l\) at \(p = 0\) and its maximum value of \(r\) at \(p = 1\). Because the CDF has range \([0, 1]\), the inverse CDF is only defined on the domain \([0, 1]\); for \(p < 0\) and \(p > 1\),
icdf
returnsnan
.The inverse CDF is also known as the quantile function, percentile function, and percent-point function.
References
[1]Quantile function, Wikipedia, https://en.wikipedia.org/wiki/Quantile_function
Examples
Instantiate a distribution with the desired parameters:
>>> import numpy as np >>> from scipy import stats >>> X = stats.Uniform(a=-0.5, b=0.5)
Evaluate the inverse CDF at the desired argument:
>>> X.icdf(0.25) -0.25 >>> np.allclose(X.cdf(X.icdf(0.25)), 0.25) True
This function returns NaN when the argument is outside the domain.
>>> X.icdf([-0.1, 0, 1, 1.1]) array([ nan, -0.5, 0.5, nan])