![]() |
Home | Libraries | People | FAQ | More |
#include <boost/math/distributions/fisher_f.hpp>
namespace boost{ namespace math{ template <class RealType = double, class Policy = policies::policy<> > class fisher_f_distribution; typedef fisher_f_distribution<> fisher_f; template <class RealType, class Policy> class fisher_f_distribution { public: typedef RealType value_type; // 構造: fisher_f_distribution(const RealType& i, const RealType& j); // 訪問函數(Accessors): RealType degrees_of_freedom1()const; RealType degrees_of_freedom2()const; }; }} //namespaces
F分佈(F distribution)是一個連續分佈,在測試兩個樣本是否有相同的方差(variance)的時候使用.。如果χ2m 和 χ2n 是獨立的變量,並且是自由度(degrees of freedom)為m和n的χ方形分佈(Chi-Squared),那麼檢驗統計量(test statistic):
Fn,m = (χ2n / n) / (χ2m / m)
在區間 [0, ∞] 是一個F分佈( F distribution),且PDF函數(概率分佈函數)為:
下面的圖像顯示了依據於兩個自由度(degree of freedom)參數的變化,PDF函數發生的變化:
fisher_f_distribution(const RealType& df1, const RealType& df2);
使用分子(numerator)自由度(degree of freedom) df1 和分母(denominator)自由度(degrees of freedom) df2來構造一個F分佈(F Distribution)。
要求:df1 和 df2 都大於0,否則調用定義域錯誤 。
RealType degrees_of_freedom1()const;
返回構造F分佈(F Distribution)的分子( numerator)自由度( degrees of freedom )參數。
RealType degrees_of_freedom2()const;
返回構造F分佈(F Distribution)的分母( denominator)自由度( degrees of freedom )參數。
支持所有的分佈都通用的 常見的非成員訪問函數 : 累積分佈函數(Cumulative Distribution Function),概率密度函數(Probability Density Function),分位點(Quantile), 故障率函數(Hazard Function), 累積危險函數(Cumulative Hazard Function), 均值(mean), 中位數(median), 眾數(mode), 方差(variance), 標準差(standard deviation), 偏斜(skewness), 峰態(kurtosis), 峰態超越(kurtosis_excess), 值域(range) 以及 支持(support)。
隨機變量的定義域為: [0, +∞]。
有多個舉例說明F分佈(F Distribution)的可運行的 例子 。
正態分佈( normal distribution)使用不完全β函數(incomplete beta function) 來實現,並且是反函數(inverses),參看這些函數瞭解精度信息。
在下面的表中:v1 和 v2 是F分佈(F Distribution)的第一個和第二個自由度(degree of freedom)參數,x 是隨機變量,p 是概率, 且 q = 1-p。
函數 |
實現註解 |
---|---|
|
PDF函數的一般形式如下:
然而,在不出現精度和數值溢出(numeric overflow)的情況下,這種形式很難直接計算。 函數CDF的直接微分(Direct differentiation)通過不完全β函數的形式來表示。 產生下面兩個方程: fv1,v2(x) = y * ibeta_derivative(v2 / 2, v1 / 2, v2 / (v2 + v1 * x)) 其中 y = (v2 * v1) / ((v2 + v1 * x) * (v2 + v1 * x)) 以及 fv1,v2(x) = y * ibeta_derivative(v1 / 2, v2 / 2, v1 * x / (v2 + v1 * x)) 其中 y = (z * v1 - x * v1 * v1) / z2 且 z = v2 + v1 * x v1 * x > v2時使用第一個方程,否則使用第二個方程。 目的是使得函數ibeta_derivative 的參數x遠離 1 來避免捨入誤差。 |
cdf |
使用下面的關係: p = ibeta(v1 / 2, v2 / 2, v1 * x / (v2 + v1 * x)) 且 p = ibetac(v2 / 2, v1 / 2, v2 / (v2 + v1 * x)) 當 v1 * x > v2使用第一個方程,否則使用第二個方程。 目的是使得函數ibeta 的參數x遠離 1 來避免捨入誤差。 |
cdf 補集(complement) |
使用下面的關係: p = ibetac(v1 / 2, v2 / 2, v1 * x / (v2 + v1 * x)) 且 p = ibeta(v2 / 2, v1 / 2, v2 / (v2 + v1 * x)) 當 v1 * x < v2時使用第一個方程,否則使用第二個方程。 目的是使得函數ibeta 的參數x遠離 1 來避免捨入誤差。 |
分位點(quantile) |
使用下面的關係: x = v2 * a / (v1 * b) 其中: a = ibeta_inv(v1 / 2, v2 / 2, p) 且 b = 1 - a 分位點(Quantities) a t b 都使用函數 ibeta_inv 來計算而沒有使用減法運算。 |
補集(complement)的分位點(quantile) |
使用下面的關係: x = v2 * a / (v1 * b) 其中: a = ibetac_inv(v1 / 2, v2 / 2, p) 且 b = 1 - a 分位點(Quantities) a t b 都使用函數ibetac_inv 來計算而沒有使用減法運算。 |
均值(mean) |
v2 / (v2 - 2) |
方差(variance) |
2 * v22 * (v1 + v2 - 2) / (v1 * (v2 - 2) * (v2 - 2) * (v2 - 4)) |
眾數(mode) |
v2 * (v1 - 2) / (v1 * (v2 + 2)) |
偏斜(skewness) |
2 * (v2 + 2 * v1 - 2) * sqrt((2 * v2 - 8) / (v1 * (v2 + v1 - 2))) / (v2 - 6) |
峰態(kurtosis)和峰態超越(kurtosis excess) |
參照,Weisstein, Eric W. "F-Distribution." From MathWorld--A Wolfram Web Resource. |