Home > wafo > wstats > wweibstat.m

wweibstat

PURPOSE ^

Mean and variance for the Weibull distribution.

SYNOPSIS ^

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

DESCRIPTION ^

 WWEIBSTAT Mean and variance for the Weibull  distribution.
  
  CALL:  [m,v] = wweibstat(a,c)
 
    m, v = the mean and variance, respectively 
    a, c = parameters of the Weibull distribution (see wweibcdf).
 
   Mean (m) and variance (v) for the Weibull distribution is
 
   m=a*gamma(1+1/c)  and  v=a^2*gamma(1+2/c)-m^2;
 
  Example:
    [m,v] = wweibstat(4,0.5)
 
  See also  wweibcdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [m,v]= wweibstat(a,c);
002 %WWEIBSTAT Mean and variance for the Weibull  distribution.
003 % 
004 % CALL:  [m,v] = wweibstat(a,c)
005 %
006 %   m, v = the mean and variance, respectively 
007 %   a, c = parameters of the Weibull distribution (see wweibcdf).
008 %
009 %  Mean (m) and variance (v) for the Weibull distribution is
010 %
011 %  m=a*gamma(1+1/c)  and  v=a^2*gamma(1+2/c)-m^2;
012 %
013 % Example:
014 %   [m,v] = wweibstat(4,0.5)
015 %
016 % See also  wweibcdf
017 
018 
019 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability
020 % and Life Span Models", p. 25 ff, Marcel Dekker.
021 
022 
023 % Tested on; Matlab 5.3
024 % History: 
025 % revised pab 23.10.2000
026 %   - added comnsize
027 % added ms 15.06.2000
028 
029 error(nargchk(2,2,nargin))
030 
031 [errorcode, a, c] = comnsize(a,c);
032 
033 if errorcode > 0
034     error('a and c must be of common size or scalar.');
035 end
036 
037 %   Initialize Mean and Variance to zero.
038 m = zeros(size(a));
039 v = zeros(size(a));
040 
041 ok = (a > 0 & c > 0);
042 k = find(ok);
043 if any(k)
044   m(k) =  a(k) .* gamma(1 + (1 ./ c(k)));
045   v(k) = a(k) .^ 2 .* gamma(1 + (2 ./ c(k))) - m(k).^ 2;
046 end
047 
048 k1 = find(~ok);
049 if any(k1)
050     tmp = NaN;
051     m(k1) = tmp(ones(size(k1)));
052     v(k1) = m(k1);   
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