Home > wafo > wstats > wbetapdf.m

wbetapdf

PURPOSE ^

Beta probability density function

SYNOPSIS ^

f = wbetapdf(x,a,b)

DESCRIPTION ^

 WBETAPDF   Beta probability density function
 
  CALL:  f = wbetapdf(x,a,b);
 
     f = density function evaluated at x
   x   = matrix
  a, b = distribution parameters
 
   The PDF is defined by:
 
    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 = wbetapdf(x,1,1); p2 = wbetapdf(x,2,2);
    plot(x,p1,x,p2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function f = wbetapdf(x,a,b)
002 %WBETAPDF   Beta probability density function
003 %
004 % CALL:  f = wbetapdf(x,a,b);
005 %
006 %    f = density function evaluated at x
007 %  x   = matrix
008 % a, b = distribution parameters
009 %
010 %  The PDF is defined by:
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 % Example: 
016 %   x = linspace(0,1,200);
017 %   p1 = wbetapdf(x,1,1); p2 = wbetapdf(x,2,2);
018 %   plot(x,p1,x,p2)
019 
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 
030 
031 
032 error(nargchk(3,3,nargin))
033 [errorcode x,a,b] = comnsize(x,a,b);
034 if errorcode>0,
035   error('x, a and b must be of common size or scalar');
036 end
037 
038 f = zeros(size(x));
039 
040 ok = (a>0 & b>0);
041 
042 k = find(x>=0&x<=1 & ok);
043 if any(k)
044   f(k) = x(k).^(a(k)-1) .* (1-x(k)).^(b(k)-1) ./ beta(a(k),b(k));
045 end
046 
047 
048 
049 
050 k=find(~ok);
051 if (any(k)),
052   F(k)=NaN;
053 end
054

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