Skip to main content
`Ctrl`+`K`
scipy.stats.Normal.

# icdf

Normal.icdf(p, /, *, method=None)

  Inverse of the cumulative distribution function.

  For monotonic continuous distributions, 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\]

  When a strict “inverse” of the cumulative distribution function does not exist (e.g. discrete random variables), the “inverse CDF” is defined by convention as the smallest value within the support \(\chi\) for which \(F(x)\) is at least \(p\).

  \[F^{-1}(p) = \min_\chi \quad \text{s.t.} \quad F(x) ≥ p\]

  `icdf` accepts p for \(p \in [0, 1]\).

  Parameters:
    p array_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:
    out array

      The inverse CDF evaluated at the provided argument.

  See also

  `cdf`
  `ilogcdf`

  Notes

  Suppose a 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` returns `nan`.

  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])