G(x)=1−F(x)=P(X>x)Atwo−argumentvariantofthisfunctionis: G(x,y)=1−F(x,y)=P(X<xorX>y) logccdf computes the logarithm of the complementary cumulative
distribution function (“log-CCDF”), log(G(x))/log(G(x,y)),
but it may be numerically favorable compared to the naive implementation
(computing the CDF and taking the logarithm).
logccdf accepts x for x and y for y.
- Parameters:
- x, y : array_like
The arguments of the log-CCDF. x is required; y is optional.
- method : {None, ‘formula’, ‘logexp’, ‘complement’, ‘quadrature’, ‘addition’}
The strategy used to evaluate the log-CCDF.
By default (None), the one-argument form of the function
chooses between the following options, listed in order of precedence.
'formula': use a formula for the log CCDF itself
'logexp': evaluate the CCDF and take the logarithm
'complement': evaluate the log-CDF and take the
logarithmic complement (see Notes)
'quadrature': numerically log-integrate the log-PDF (or, in the
discrete case, log-sum the log-PMF)
The two-argument form chooses between:
'formula': use a formula for the log CCDF itself
'addition': compute the log-CDF at x and the log-CCDF at y,
then take the logarithmic sum (see Notes)
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 log-CCDF evaluated at the provided argument(s).
Notes
Suppose a continuous probability distribution has support [l,r].
The log-CCDF returns its minimum value of log(0)=−∞ for
x≥r and its maximum value of log(1)=0 for
x≤l. An analogous statement can be made for discrete distributions,
but the inequality governing the maximum value is strict.
For distributions with infinite support, it is common for
ccdf to return a value of 0 when the argument
is theoretically within the support; this can occur because the true value
of the CCDF is too small to be represented by the chosen dtype. The log
of the CCDF, however, will often be finite (not -inf) over a much larger
domain. Similarly, logccdf may provided a strictly negative result with
arguments for which ccdf would return 1.0. Consequently, it may be
preferred to work with the logarithms of probabilities to avoid underflow
and related limitations of floating point numbers.
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.
Similarly, the term “logarithmic sum” of w and z
is used here to mean the log(exp(w)+exp(z)), AKA
LogSumExp(w,z).
References
Examples