前段时间,遇到一个求非中心卡方分布累积分布函数的积分的问题,记录一下,自己留用。
1、什么是非中心卡方分布
非中心卡方分布的随机变量是由若干个独立同方差均值不为0的高斯随机变量的平方和得到的。
MATLAB中有函数ncx2pdf(x,d,lamda)可以查看非中心卡方分布的概率密度函数图形
其中d为非中心卡方分布的自由度,lamda为非中心参数;
2、非中心卡方分布的CDF
(1)函数ncx2cdf
示例:
x = (0:0.1:10)';
ncx2 = ncx2cdf(x,4,2);
plot(x,ncx2,'b-','LineWidth',2)
hold on;
上图是自由度为4,非中心参数为2的卡方分布的CDF
(2)积分的方法
示例1:
ncx2=@(x)ncx2pdf(x,4,2);
a = quadgk(ncx2,0,10)
a =
0.8512
示例2:
x = 0:0.1:10;
ncx2=ncx2pdf(x,4,2);
b = trapz(x,ncx2)
b =
0.8511
(3)利用marcumq函数
marcumq函数与ncx2的cdf关系可以从下面两张图看出
Q = marcumq(a,b) computes the Marcum Q function of a and b, defined by
where a and b are nonnegative real numbers. In this expression, I0 is the modified Bessel function of the first kind of zero order.
Q = marcumq(a,b,m) computes the generalized Marcum Q, defined by
where a and b are nonnegative real numbers, and m is a positive integer. In this expression, Im–1 is the modified Bessel function of the first kind of order m–1;
If any of the inputs is a scalar, it is expanded to the size of the other inputs.
c =1-marcumq(sqrt(2),sqrt(10),2)
c =
0.8512
3、高斯随机变量的二次型