Mathematically, it is equivalent to F−1(exp(y)), where
y=log(p), but it may be numerically favorable compared to
the naive implementation (computing p=exp(y), then
F−1(p)).
ilogcdf accepts logp for log(p)≤0.
- 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 [l,r].
The inverse log-CDF returns its minimum value of l at
log(p)=log(0)=−∞ and its maximum value of r at
log(p)=log(1)=0. Because the log-CDF has range
[−∞,0], the inverse log-CDF is only defined on the
negative reals; for log(p)>0, 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 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