Home > wafo > wstats > wbetastat.m

wbetastat

PURPOSE ^

Mean and variance for the Beta distribution.

SYNOPSIS ^

[m,v]= wbetastat(a,c);

DESCRIPTION ^

 WBETASTAT Mean and variance for the Beta distribution. 
   
  CALL:  [m,v] = wbetastat(df1,df2) 
  
    m,  v = the mean and variance, respectively  
    a,  b = parameters of the Beta distribution 
  
   Mean (m) and variance (v) for the Beta distribution is 
  
       m = a/(a+b) and v = a*b/(a+b)^2/(a+b+1)  if a>0, b>0 
  
  See also  wbetapdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [m,v]= wbetastat(a,c); 
002 %WBETASTAT Mean and variance for the Beta distribution. 
003 %  
004 % CALL:  [m,v] = wbetastat(df1,df2) 
005 % 
006 %   m,  v = the mean and variance, respectively  
007 %   a,  b = parameters of the Beta distribution 
008 % 
009 %  Mean (m) and variance (v) for the Beta distribution is 
010 % 
011 %      m = a/(a+b) and v = a*b/(a+b)^2/(a+b+1)  if a>0, b>0 
012 % 
013 % See also  wbetapdf 
014  
015  
016 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability 
017 % and Life Span Models", Marcel Dekker. 
018  
019  
020 % Tested on; Matlab 5.3 
021 % History:  
022 % by pab 23.10.2000 
023  
024 error(nargchk(2,2,nargin)) 
025 [errorcode, a, c] = comnsize(a,c); 
026 if errorcode > 0 
027     error('a and b must be of common size or scalar.'); 
028 end 
029  
030  
031 %   Initialize Mean and Variance to zero. 
032 m = zeros(size(a)); 
033 v = zeros(size(a)); 
034  
035 ok = (a > 0  & c > 0 ); 
036 k = find(ok); 
037 if any(k) 
038   m(k) = a(k)./(a(k)+c(k)); 
039   v(k) = m(k).*c(k)./(a(k)+c(k))./(a(k)+c(k)+1); 
040 end 
041  
042 k1 = find(~ok); 
043 if any(k1) 
044   warning('a and b should be positive') 
045   tmp = NaN; 
046   v(k1) = tmp(ones(size(k1))); 
047   m(k) = v(k1); 
048 end 
049  
050  
051

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