{ } Raw JSON

bundles / scipy latest / scipy / stats / _probability_distribution / _ProbabilityDistribution / ilogcdf

function

scipy.stats._probability_distribution:_ProbabilityDistribution.ilogcdf

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

Signature

def   ilogcdf ( self logp / method )

Summary

Inverse of the logarithm of the cumulative distribution function.

Extended Summary

The inverse of the logarithm of the cumulative distribution function ("inverse log-CDF") is the argument for which the logarithm of the cumulative distribution function evaluates to .

Mathematically, it is equivalent to , where , but it may be numerically favorable compared to the naive implementation (computing , then ).

ilogcdf accepts logp for .

Parameters

logp : array_like

The argument of the inverse log-CDF.

method : {None, 'formula', 'complement', 'inversion'}

The strategy used to evaluate the inverse log-CDF. By default (None), the infrastructure chooses between the following options, listed in order of precedence.

  • 'formula': use a formula for the inverse log-CDF itself

  • 'complement': evaluate the inverse log-CCDF at the logarithmic complement of logp (see Notes)

  • 'inversion': solve numerically for the argument at which the log-CDF is equal to logp

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 log-CDF evaluated at the provided argument.

Notes

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

Occasionally, it is needed to find the argument of the CDF for which the resulting probability is very close to 0 or 1 - too close to represent accurately with floating point arithmetic. In many cases, however, the logarithm of this resulting probability may be represented in floating point arithmetic, in which case this function may be used to find the argument of the CDF for which the logarithm of the resulting probability is .

The "logarithmic complement" of a number is mathematically equivalent to , but it is computed to avoid loss of precision when is nearly or .

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 log-CDF at the desired argument:
X.ilogcdf(-0.25)
np.allclose(X.ilogcdf(-0.25), X.icdf(np.exp(-0.25)))

See also

icdf
logcdf

Aliases

  • scipy.stats._distribution_infrastructure._ProbabilityDistribution.ilogcdf