Home > wafo > wstats > wgamcdf.m

wgamcdf

PURPOSE ^

Gamma cumulative distribution function

SYNOPSIS ^

F = wgamcdf(x,a,b);

DESCRIPTION ^

 WGAMCDF Gamma cumulative distribution function
 
  CALL:  F = wgamcdf(x,a,b);
 
         F = distribution function evaluated at x
         a = parameter
         b = parameter (default b=1)
 
  The Gamma distribution is defined by its pdf
 
         f(x)=x^(a-1)*exp(-x/b)/gamma(a)/b^a, a,b>0, x>=0.
 
  Example: 
    x = linspace(0,7,200);
    p1 = wgamcdf(x,1); p2 = wgamcdf(x,2);
    plot(x,p1,x,p2)
 
  See also  wggamcdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function F = wgamcdf(x,a,b);
002 %WGAMCDF Gamma cumulative distribution function
003 %
004 % CALL:  F = wgamcdf(x,a,b);
005 %
006 %        F = distribution function evaluated at x
007 %        a = parameter
008 %        b = parameter (default b=1)
009 %
010 % The Gamma distribution is defined by its pdf
011 %
012 %        f(x)=x^(a-1)*exp(-x/b)/gamma(a)/b^a, a,b>0, x>=0.
013 %
014 % Example: 
015 %   x = linspace(0,7,200);
016 %   p1 = wgamcdf(x,1); p2 = wgamcdf(x,2);
017 %   plot(x,p1,x,p2)
018 %
019 % See also  wggamcdf
020 
021 % Reference: Johnson, Kotz and Balakrishnan (1994)
022 % "Continuous Univariate Distributions, vol. 1", p. 494 ff
023 % Wiley
024 
025 % Tested on; Matlab 5.3
026 % History:
027 % revised pab 24.10.2000
028 %  - added comnsize, nargchk
029 % added ms 26.06.2000
030 % added b parameter ms 23.08.2000
031 
032 
033 error(nargchk(2,3,nargin))
034 
035 if nargin<3|isempty(b),  b=1; end
036 
037 [errorcode x a b] = comnsize(x,a,b);
038 
039 if errorcode > 0
040   error('x, a and b must be of common size or scalar.');
041 end
042 F = zeros(size(x));
043 
044 ok= ((a >0) & (b> 0));
045 
046 
047 k=find(x > 0 & ok);
048 if any(k),
049   F(k)= gammainc(x(k)./b(k),a(k));
050 end
051 
052 %   Return NaN if the arguments are outside their respective limits.
053 k3 = find(~ok);     
054 if any(k3)
055   tmp = NaN;
056   F(k3) = tmp(ones(size(k3)));
057 end
058 
059 
060 
061 
062 
063 
064 
065

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003