scipy.special.log_ndtr#
- scipy.special.log_ndtr(x, out=None) = <ufunc 'log_ndtr'>#
Logarithm of Gaussian cumulative distribution function.
Returns the log of the area under the standard Gaussian probability density function, integrated from minus infinity to x:
log(1/sqrt(2*pi) * integral(exp(-t**2 / 2), t=-inf..x))
- Parameters:
- xarray_like, real or complex
Argument
- outndarray, optional
Optional output array for the function results
- Returns:
- scalar or ndarray
The value of the log of the normal CDF evaluated at x
See also
Notes
Array API Standard Support
log_ndtrhas support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
✅
JAX
✅
✅
Dask
✅
n/a
For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support
out, but none of the other ufunc kwargs.outis typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend.outis never supported for JAX because JAX arrays are immutable.See Support for the array API standard for more information.
Examples
>>> import numpy as np >>> from scipy.special import log_ndtr, ndtr
The benefit of
log_ndtr(x)over the naive implementationnp.log(ndtr(x))is most evident with moderate to large positive values ofx:>>> x = np.array([6, 7, 9, 12, 15, 25]) >>> log_ndtr(x) array([-9.86587646e-010, -1.27981254e-012, -1.12858841e-019, -1.77648211e-033, -3.67096620e-051, -3.05669671e-138])
The results of the naive calculation for the moderate
xvalues have only 5 or 6 correct significant digits. For values ofxgreater than approximately 8.3, the naive expression returns 0:>>> np.log(ndtr(x)) array([-9.86587701e-10, -1.27986510e-12, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00])