scipy.special.ndtri#
- scipy.special.ndtri(y, out=None) = <ufunc 'ndtri'>#
ndtr
對 x 的反函數返回參數 x,使得標準常態機率密度函數(從負無限大積分到 x)之下的面積等於 y。
- 參數:
- parray_like
機率
- outndarray, optional
函數結果的選用輸出陣列
- 返回值:
- xscalar or ndarray
x 的值,使得
ndtr(x) == p
。
範例
ndtri
是標準常態分布的百分位數函數。這表示它返回累積密度ndtr
的反函數。首先,讓我們計算一個累積密度值。>>> import numpy as np >>> from scipy.special import ndtri, ndtr >>> cdf_val = ndtr(2) >>> cdf_val 0.9772498680518208
驗證
ndtri
對於 x 產生原始值,直到浮點誤差為止。>>> ndtri(cdf_val) 2.0000000000000004
繪製函數圖。為此,我們提供一個 NumPy 陣列作為參數。
>>> import matplotlib.pyplot as plt >>> x = np.linspace(0.01, 1, 200) >>> fig, ax = plt.subplots() >>> ax.plot(x, ndtri(x)) >>> ax.set_title("Standard normal percentile function") >>> plt.show()