{ } Raw JSON

bundles / scipy latest / scipy / stats / _probability_distribution / _ProbabilityDistribution / ilogccdf

function

scipy.stats._probability_distribution:_ProbabilityDistribution.ilogccdf

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

Signature

def   ilogccdf ( self logp / method )

Summary

Inverse of the log of the complementary cumulative distribution function.

Extended Summary

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

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

ilogccdf accepts logp for .

Parameters

x : array_like

The argument of the inverse log-CCDF.

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

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

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

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

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

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

Notes

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

Occasionally, it is needed to find the argument of the CCDF 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 CCDF 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-CCDF at the desired argument:
X.ilogccdf(-0.25)
np.allclose(X.ilogccdf(-0.25), X.iccdf(np.exp(-0.25)))

See also

iccdf
ilogccdf

Aliases

  • scipy.stats._distribution_infrastructure._ProbabilityDistribution.ilogccdf