Home > wafo > wstats > wfstat.m

wfstat

PURPOSE ^

Mean and variance for the Snedecor's F distribution.

SYNOPSIS ^

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

DESCRIPTION ^

 WFSTAT Mean and variance for the Snedecor's F distribution. 
   
  CALL:  [m,v] = wfstat(df1,df2) 
  
    m,  v   = the mean and variance, respectively  
   df1, df2 = degrees of freedom of the F distribution 
  
   Mean (m) and variance (v) for the F distribution is 
  
       m = df2/(df2-1)                  if df2>2   
  and   
       v=2*m^2*(df1+df2-2)/(df2-4)/df1  if df2>4 
  
  See also  wfpdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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