Home > wafo > wstats > wbetacdf.m

wbetacdf

PURPOSE ^

Beta cumulative distribution function

SYNOPSIS ^

F = wbetacdf(x,a,b)

DESCRIPTION ^

 WBETACDF   Beta cumulative distribution function
 
  CALL:  F = wbetacdf(x,a,b);
 
         F = distribution function evaluated at x
         x = matrix
       a,b = distribution parameters
 
   It is defined by its PDF:
 
    f = x^(a-1)*(1-x)^(b-1)/H(a,b)    0<= x <= 1, a>0, b>0
  
  where H(a,b) is a normalization constant.
    
  Example: 
    x = linspace(0,1,200);
    p1 = wbetacdf(x,1,1); p2 = wbetacdf(x,2,2);
    plot(x,p1,x,p2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function F = wbetacdf(x,a,b)
002 %WBETACDF   Beta cumulative distribution function
003 %
004 % CALL:  F = wbetacdf(x,a,b);
005 %
006 %        F = distribution function evaluated at x
007 %        x = matrix
008 %      a,b = distribution parameters
009 %
010 %  It is defined by its PDF:
011 %
012 %   f = x^(a-1)*(1-x)^(b-1)/H(a,b)    0<= x <= 1, a>0, b>0
013 % 
014 % where H(a,b) is a normalization constant.
015 %   
016 % Example: 
017 %   x = linspace(0,1,200);
018 %   p1 = wbetacdf(x,1,1); p2 = wbetacdf(x,2,2);
019 %   plot(x,p1,x,p2)
020 
021 % tested on matlab 5.3
022 %History:
023 %revised pab 29.10.2000
024 % adapted from stixbox
025 % -added nargchk, comnsize
026 %       Anders Holtsberg, 18-11-93
027 %       Copyright (c) Anders Holtsberg
028 
029 error(nargchk(3,3,nargin))
030 [errorcode x,a,b] = comnsize(x,a,b);
031 if errorcode>0,
032   error('x, a and b must be of common size or scalar');
033 end
034 
035 F = zeros(size(x));
036 
037 ok = (a>0 & b>0);
038 
039 Ii = find(x>0&x<1 & ok);
040 if any(Ii)
041    F(Ii) = betainc(x(Ii),a(Ii),b(Ii));
042 end
043 
044 Iu = find(x>=1);
045 if any(Iu)
046   F(Iu) = ones(size(Iu));
047 end
048 
049 k=find(~ok);
050 if (any(k)),
051   F(k)=NaN;
052 end
053 
054 
055 
056 
057 
058

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