Home > wafo > wstats > wfrechstat.m

wfrechstat

PURPOSE ^

Mean and variance for the Frechet distribution.

SYNOPSIS ^

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

DESCRIPTION ^

 WFRECHSTAT Mean and variance for the Frechet distribution.
  
  CALL:  [m,v] = wfrechstat(a,c)
 
    m, v = the mean and variance, respectively 
    a, c = parameters of the Frechet distribution (see wfrechcdf).
 
   Mean (m) and variance (v) for the Frechet distribution is
 
   m=a*gamma(1-1/c)  (if c>1) and  v=a^2*(gamma(1-2/c))-m^2  (if c>2)
 
  Example:
    [m,v] = wweibstat(4,0.5)
 
  See also  wfrechcdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [m,v]= wfrechstat(a,c);
002 %WFRECHSTAT Mean and variance for the Frechet distribution.
003 % 
004 % CALL:  [m,v] = wfrechstat(a,c)
005 %
006 %   m, v = the mean and variance, respectively 
007 %   a, c = parameters of the Frechet distribution (see wfrechcdf).
008 %
009 %  Mean (m) and variance (v) for the Frechet distribution is
010 %
011 %  m=a*gamma(1-1/c)  (if c>1) and  v=a^2*(gamma(1-2/c))-m^2  (if c>2)
012 %
013 % Example:
014 %   [m,v] = wweibstat(4,0.5)
015 %
016 % See also  wfrechcdf
017 
018 
019 % Reference: 
020 
021 
022 % Tested on; Matlab 5.3
023 % History: 
024 % Added PJ 10-May-2001
025 
026 error(nargchk(2,2,nargin))
027 
028 [errorcode, a, c] = comnsize(a,c);
029 
030 if errorcode > 0
031     error('a and c must be of common size or scalar.');
032 end
033 
034 %   Initialize Mean and Variance to zero.
035 m = zeros(size(a));
036 v = zeros(size(a));
037 
038 %ok = (a > 0 & c > 0);
039 ok1 = (a > 0 & c > 1);
040 ok2 = (a > 0 & c > 2);
041 
042 k = find(ok1);
043 if any(k)
044   m(k) =  a(k) .* gamma(1 - (1 ./ c(k)));
045 end
046 
047 k = find(ok2);
048 if any(k)
049   v(k) = a(k) .^ 2 .* gamma(1 - (2 ./ c(k))) - m(k).^ 2;
050 end
051 
052 k1 = find(~ok1);
053 if any(k1)
054     tmp = NaN;
055     m(k1) = tmp(ones(size(k1)));
056 end
057 
058 k1 = find(~ok2);
059 if any(k1)
060     tmp = NaN;
061     v(k1) = tmp(ones(size(k1)));
062 end
063

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