numpy.random.RandomState.noncentral_f

原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.RandomState.noncentral_f.html

译者:飞龙 UsyiyiCN

校对:(虚位以待)

RandomState.noncentral_f(dfnum, dfden, nonc, size=None)

从非中心F分布中抽取样本。

Samples are drawn from an F distribution with specified parameters, dfnum (degrees of freedom in numerator) and dfden (degrees of freedom in denominator), where both parameters > 1. nonc is the non-centrality parameter.

参数:

dfnum:int

参数,应> 1。

dfden:int

参数,应> 1。

nonc:float

参数,应为> = 0。

size:int或tuple的整数,可选

输出形状。如果给定形状是例如(m, n, k),则 m * n * k默认值为None,在这种情况下返回单个值。

返回:

samples:scalar或ndarray

绘制样品。

笔记

当计算实验的功率(功率=当特定替代为真时拒绝零假设的概率),非中心F统计变得重要。当零假设为真时,F统计遵循中心F分布。当零假设不为真时,则遵循非中心F统计量。

参考文献

[R176]Weisstein,Eric W.“非中心F分布”。来自MathWorld-Wolfram Web资源。http://mathworld.wolfram.com/NoncentralF-Distribution.html
[R177]维基百科,“非中心F分布”,http://en.wikipedia.org/wiki/Noncentral_F-distribution

例子

在一项研究中,对零假设的特定替代的测试需要使用非中心F分布。我们需要计算超过零假设的F分布值的分布尾部的面积。我们将绘制两个概率分布用于比较。

>>> dfnum = 3 # between group deg of freedom
>>> dfden = 20 # within groups degrees of freedom
>>> nonc = 3.0
>>> nc_vals = np.random.noncentral_f(dfnum, dfden, nonc, 1000000)
>>> NF = np.histogram(nc_vals, bins=50, normed=True)
>>> c_vals = np.random.f(dfnum, dfden, 1000000)
>>> F = np.histogram(c_vals, bins=50, normed=True)
>>> plt.plot(F[1][1:], F[0])
>>> plt.plot(NF[1][1:], NF[0])
>>> plt.show()