scipy.special.ndtri#
- scipy.special.ndtri(p, out=None) = <ufunc 'ndtri'>#
Inverse of
ndtr.Returns the quantile x such that the cumulative distribution function of the standard normal distribution evaluated at x equals p, that is,
ndtr(x) == p.- Parameters:
- parray_like
Probability values.
- outndarray, optional
Optional output array for the function results.
- Returns:
- xscalar or ndarray
Quantile(s) corresponding to the probabilitie(s) in p.
Notes
Array API Standard Support
ndtrihas 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
ndtriis the percentile (quantile) function of the standard normal distribution, i.e., the inverse of the cumulative distribution functionndtr.First, compute a cumulative distribution value:
>>> import numpy as np >>> from scipy.special import ndtri, ndtr >>> cdf_val = ndtr(2) >>> cdf_val 0.9772498680518208
Verify that
ndtriyields the original value for x up to floating point errors.>>> ndtri(cdf_val) 2.0000000000000004
Plot the percentile function over a range of probabilities.
>>> import matplotlib.pyplot as plt >>> p = np.linspace(1e-3, 1 - 1e-3, 201) >>> fig, ax = plt.subplots() >>> ax.plot(p, ndtri(p)) >>> ax.set_title("Standard normal percentile function") >>> plt.show()