Home > General-Functions > external > ncx2cdf.m

ncx2cdf

PURPOSE ^

NCX2CDF Noncentral chi-square cumulative distribution function (cdf).

SYNOPSIS ^

function p = ncx2cdf(x,v,delta)

DESCRIPTION ^

NCX2CDF Noncentral chi-square cumulative distribution function (cdf).
   P = NCX2CDF(X,V,DELTA) Returns the noncentral chi-square cdf with V 
   degrees of freedom and noncentrality parameter, DELTA, at the values 
   in X.

   The size of P is the common size of the input arguments. A scalar input  
   functions as a constant matrix of the same size as the other inputs.     

   Some texts refer to this distribution as the generalized Rayleigh,
   Rayleigh-Rice, or Rice distribution.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function p = ncx2cdf(x,v,delta)
0002 %NCX2CDF Noncentral chi-square cumulative distribution function (cdf).
0003 %   P = NCX2CDF(X,V,DELTA) Returns the noncentral chi-square cdf with V
0004 %   degrees of freedom and noncentrality parameter, DELTA, at the values
0005 %   in X.
0006 %
0007 %   The size of P is the common size of the input arguments. A scalar input
0008 %   functions as a constant matrix of the same size as the other inputs.
0009 %
0010 %   Some texts refer to this distribution as the generalized Rayleigh,
0011 %   Rayleigh-Rice, or Rice distribution.
0012 
0013 %   Reference:
0014 %      [1]  Evans, Merran, Hastings, Nicholas and Peacock, Brian,
0015 %      "Statistical Distributions, Second Edition", Wiley
0016 %      1993 p. 50-52.
0017 
0018 %   B.A. Jones 4-29-94
0019 %   Copyright (c) 1993-98 by The MathWorks, Inc.
0020 %   $Revision: 2.7 $  $Date: 1997/12/17 21:40:15 $
0021 
0022 if nargin <  3, 
0023     error('Requires three input arguments.'); 
0024 end
0025 
0026 [errorcode x v delta] = distchck(3,x,v,delta);
0027 
0028 if errorcode > 0
0029     error('Requires non-scalar arguments to match in size.');
0030 end
0031 
0032 % Initialize P to zero.
0033 p = zeros(size(x));
0034 
0035 % Set up for infinite sum.
0036 done = 0;
0037 counter = 0;
0038 
0039 % Sum the series.
0040 s = sqrt(eps);
0041 while ~done
0042    pplus = poisspdf(counter,delta/2).*chi2cdf(x,v+2*counter);
0043    p = p + pplus;
0044 
0045    % Convergence test.
0046    k = find(~isnan(pplus));
0047    if all((pplus(k)./(p(k)+s)) < s)
0048       done = 1;
0049    end
0050    counter = counter + 1;
0051 end

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005