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 experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_ARRAY_API=1and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. 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
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()