scipy.stats.Mixture.

ilogccdf#

Mixture.ilogccdf(p, /, *, method=None)[source]#

Inverse of the log of the complementary cumulative distribution function.

The inverse of the logarithm of the complementary cumulative distribution function (“inverse log-CCDF”) is the argument \(x\) for which the logarithm of the complementary cumulative distribution function \(\log(G(x))\) evaluates to \(\log(p)\).

Mathematically, it is equivalent to \(G^{-1}(\exp(y))\), where \(y = \log(p)\), but it may be numerically favorable compared to the naive implementation (computing \(p = \exp(y)\), then \(G^{-1}(p)\)).

ilogccdf accepts logp for \(\log(p) ≤ 0\).

Parameters:
xarray_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:
outarray

The inverse log-CCDF evaluated at the provided argument.

See also

iccdf
ilogccdf

Notes

Suppose a continuous probability distribution has support \([l, r]\). The inverse log-CCDF returns its minimum value of \(l\) at \(\log(p) = \log(1) = 0\) and its maximum value of \(r\) at \(\log(p) = \log(0) = -\infty\). Because the log-CCDF has range \([-\infty, 0]\), the inverse log-CDF is only defined on the negative reals; for \(\log(p) > 0\), 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 y = log(p).

The “logarithmic complement” of a number \(z\) is mathematically equivalent to \(\log(1-\exp(z))\), but it is computed to avoid loss of precision when \(\exp(z)\) is nearly \(0\) or \(1\).

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)
-0.2788007830714034
>>> np.allclose(X.ilogccdf(-0.25), X.iccdf(np.exp(-0.25)))
True