% Written by Min-Hua Huang
% June 9, 2011
% Testing two cumulative distribution functions related to the Marcum Q-function with the "h" factorization method.
% Section 4.7 in "Indefinite Integration of the Gamma Integral".
% c is an considerably larger number, as a proxy of the infinite upper limit. 
clear; clc; format long; pre=300; c=100; digits(700); 
fprintf('Testing two distribution functions associated with the Marcum Q-function:\n\n');
% ************************************************************************
% Noncentral chi-square distribution
x=1.5; k=4; lamda=3; 
answer1=ncx2cdf(x,k,lamda);
check1=1-hmQ(sqrt(lamda),sqrt(x),k/2);
fprintf('Noncentral chi-square=%8.5f, huang method=%8.5f,\n',answer1,check1);
% ************************************************************************
% Rice distribution
v=7; sigma=2.3; x=3.5;
a=v/sigma; b=x/sigma; m=1;
answer2=1-marcumq(a,b,m);
check2=1-hmQ(a,b,m);
fprintf('Rice=%8.5f, huang method=%8.5f.\n\n',answer2,check2);