scipy.special.ncfdtr#

scipy.special.ncfdtr(dfn, dfd, nc, f, out=None) = <ufunc 'ncfdtr'>#

非中心F分布的累积分布函数。

非中心F分布描述了以下变量的分布:

\[Z = \frac{X/d_n}{Y/d_d}\]

其中 \(X\)\(Y\) 独立分布,\(X\) 服从非中心 \(\chi^2\) 分布,其非中心参数为 nc,自由度为 \(d_n\)\(Y\) 服从 \(\chi^2\) 分布,自由度为 \(d_d\)

参数:
dfn类数组对象

分子平方和的自由度。范围 (0, 无穷大)。

dfd类数组对象

分母平方和的自由度。范围 (0, 无穷大)。

nc类数组对象

非中心参数。范围 [0, 无穷大)。

f类数组对象

分位数,即积分上限。

outndarray, 可选

可选的输出数组,用于存放函数结果

返回:
cdf标量或 ndarray

计算得到的CDF值。如果所有输入都是标量,返回值为浮点数。否则,返回值为数组。

另请参见

ncfdtri

分位数函数;关于 fncfdtr 逆函数。

ncfdtridfd

关于 dfdncfdtr 逆函数。

ncfdtridfn

关于 dfnncfdtr 逆函数。

ncfdtrinc

关于 ncncfdtr 逆函数。

scipy.stats.ncf

非中心F分布。

说明

此函数使用 Boost Math C++ 库 [1] 计算非中心f分布的CDF。

累积分布函数通过 [2] 中的公式 26.6.20 计算:

\[F(d_n, d_d, n_c, f) = \sum_{j=0}^\infty e^{-n_c/2} \frac{(n_c/2)^j}{j!} I_{x}(\frac{d_n}{2} + j, \frac{d_d}{2}),\]

其中 \(I\) 是正则不完全Beta函数,\(x = f d_n/(f d_n + d_d)\)

请注意,ncfdtr 的参数顺序与 scipy.stats.ncf 中相似的 cdf 方法的参数顺序不同:fncfdtr 的最后一个参数,却是 scipy.stats.ncf.cdf 的第一个参数。

参考文献

[1]

The Boost Developers. “Boost C++ Libraries”. https://boost.ac.cn/.

[2]

Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.

示例

>>> import numpy as np
>>> from scipy import special
>>> from scipy import stats
>>> import matplotlib.pyplot as plt

绘制非中心F分布的CDF,当 nc=0 时。与 scipy.stats 中的F分布进行比较。

>>> x = np.linspace(-1, 8, num=500)
>>> dfn = 3
>>> dfd = 2
>>> ncf_stats = stats.f.cdf(x, dfn, dfd)
>>> ncf_special = special.ncfdtr(dfn, dfd, 0, x)
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> ax.plot(x, ncf_stats, 'b-', lw=3)
>>> ax.plot(x, ncf_special, 'r-')
>>> plt.show()
../../_images/scipy-special-ncfdtr-1.png