Home > wafo > wstats > wgpdstat.m

wgpdstat

PURPOSE ^

Mean and variance for the Generalized Pareto distribution.

SYNOPSIS ^

[m,v]= wgpdstat(k,s,m0);

DESCRIPTION ^

 WGPDSTAT Mean and variance for the Generalized Pareto distribution.
  
  CALL:  [m,v] = wgpdstat(k,s,m0)
 
        m, v = the mean and variance, respectively 
   k, s, m0  = parameters of the  Generalized Pareto distribution
               (see wgpdcdf).
 
  Mean (m) and variance (v) for the Generalized Pareto distribution is
 
   m=m0+s/(1+k)  and
   v=s^2/((1+k)^2*(1+2k))
 
  The mean does not exist for k<-1, and the variance does not exist for 
  k<-0.5.
 
  Example:
    [m,v] = wgpdstat(1,10,10)
    [m,v] = wgpdstat(-0.75,1,0)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [m,v]= wgpdstat(k,s,m0);
002 %WGPDSTAT Mean and variance for the Generalized Pareto distribution.
003 % 
004 % CALL:  [m,v] = wgpdstat(k,s,m0)
005 %
006 %       m, v = the mean and variance, respectively 
007 %  k, s, m0  = parameters of the  Generalized Pareto distribution
008 %              (see wgpdcdf).
009 %
010 % Mean (m) and variance (v) for the Generalized Pareto distribution is
011 %
012 %  m=m0+s/(1+k)  and
013 %  v=s^2/((1+k)^2*(1+2k))
014 %
015 % The mean does not exist for k<-1, and the variance does not exist for 
016 % k<-0.5.
017 %
018 % Example:
019 %   [m,v] = wgpdstat(1,10,10)
020 %   [m,v] = wgpdstat(-0.75,1,0)
021 
022 
023 % Tested on; Matlab 5.3
024 % History: 
025 % Revised by PJ 02-Apr-2001
026 %  - Added non-existing mean and var (k<-1 and k<-0.5).
027 % revised pab 24.10.2000
028 %  - added comnsize, nargchk + default value for s and m0
029 % added ms 09.08.2000
030 
031 error(nargchk(1,3,nargin))
032 if nargin<2,  s=1;end
033 if nargin<3,  m0=0;end
034 [errorcode k,s,m0] = comnsize(k,s,m0);
035 if errorcode > 0
036     error('k s and m0 must be of common size or scalar.');
037 end
038 
039 % Initialize  m  and v to zero.
040 m = zeros(size(k));
041 v=m;
042 
043 k1=find(s>0);
044 if any(k1),
045   m(k1) =m0(k1)+ s(k1)./(1+k(k1));
046 v(k1) = s(k1).^2./((1+k(k1)).^2.*(1+2*k(k1)));
047 end
048 
049 k2=find(s<=0);
050 if any(k2),
051   m(k2) = NaN;
052   v(k2) = NaN;
053 end
054 
055 % Variance doesn't exist for k<-0.5
056 k2=find(k<-0.5);
057 if any(k2),
058   v(k2) = NaN;
059 end
060 
061 % Mean doesn't exist for k<-0.5
062 k2=find(k<-1);
063 if any(k2),
064   m(k2) = NaN;
065 end
066

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