Home Libraries People FAQ More

##### 非中心χ方形分佈(Noncentral Chi-Squared Distribution)

`#include <boost/math/distributions/non_central_chi_squared.hpp>`

```namespace boost{ namespace math{

template <class RealType = double,
class Policy   = policies::policy<> >
class non_central_chi_squared_distribution;

typedef non_central_chi_squared_distribution<> non_central_chi_squared;

template <class RealType, class Policy>
class non_central_chi_squared_distribution
{
public:
typedef RealType  value_type;
typedef Policy    policy_type;

// 構造函數:
non_central_chi_squared_distribution(RealType v, RealType lambda);

// 自由度(degree of freedom)參數v訪問函數(Accessor):
RealType degrees_of_freedom()const;

// 非中心(non centrality)參數lambda訪問函數(Accessor):
RealType non_centrality()const;

// 參數查找:
static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
template <class A, class B, class C>
static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);

static RealType find_non_centrality(RealType v, RealType x, RealType p);
template <class A, class B, class C>
static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
};

}} // namespaces
```

(注意：一些資料中將λ 定義為上面和的一半)。

##### 成員函數
```non_central_chi_squared_distribution(RealType v, RealType lambda);
```

```RealType degrees_of_freedom()const;
```

```RealType non_centrality()const;
```

```static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
```

```template <class A, class B, class C>
static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);
```

```cdf(complement(non_central_chi_squared<RealType, Policy>(v, lambda), x)) == q```.

```static RealType find_non_centrality(RealType v, RealType x, RealType p);
```

```cdf(non_central_chi_squared<RealType, Policy>(v, lambda), x) == p```

```template <class A, class B, class C>
static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
```

```cdf(complement(non_central_chi_squared<RealType, Policy>(v, lambda), x)) == q```.

##### 精確度

ν,λ < 200

ν,λ > 200

53

Win32, Visual C++ 8

R 峰值=685 均值=109

R 峰值=3x108 均值=2x107

64

RedHat Linux IA32, gcc-4.1.1

64

Redhat Linux IA64, gcc-3.4.4

113

HPUX IA64, aCC A.06.06

CDF函數的補集與分位點(quantile)函數的誤差率大體上是相同的。需要特別提及一下眾數(mode)函數： 這個分佈並沒有閉型(closed form)，因此眾數是通過在數值上查找PDF函數的最大值來計算的：在原理上，這無法產生一個比machine epsilon的平方根更高的精確度。

##### 實現

CDF函數以及其補集使用下面的方法計算：

F(ν,λ;ν+λ) ≒ 0.5

CDF補集(complement)的計算使用擴展的 Krishnamoorthy方法，給定：

Andrea van Aubel & Wolfgang Gawronski, Applied Mathematics and Computation, 141 (2003) 3-12.