{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _probability_distribution / _ProbabilityDistribution / icdf

function

scipy.stats._probability_distribution:_ProbabilityDistribution.icdf

source: /scipy/stats/_probability_distribution.py :1134

Signature

def   icdf ( self p / method )

Summary

Inverse of the cumulative distribution function.

Extended Summary

For monotonic continuous distributions, the inverse of the cumulative distribution function ("inverse CDF"), denoted , is the argument for which the cumulative distribution function evaluates to .

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 for which is at least .

icdf accepts p for .

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.

Notes

Suppose a probability distribution has support . The inverse CDF returns its minimum value of at and its maximum value of at . Because the CDF has range , the inverse CDF is only defined on the domain ; for and , icdf returns nan.

The inverse CDF is also known as the quantile function, percentile function, and percent-point 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)
np.allclose(X.cdf(X.icdf(0.25)), 0.25)
This function returns NaN when the argument is outside the domain.
X.icdf([-0.1, 0, 1, 1.1])

See also

cdf
ilogcdf

Aliases

  • scipy.stats._distribution_infrastructure._ProbabilityDistribution.icdf