Home > wafo > wstats > wgevinv.m

wgevinv

PURPOSE ^

Inverse of the Generalized Extreme Value distribution function

SYNOPSIS ^

x = wgevinv(F,k,s,m)

DESCRIPTION ^

 WGEVINV Inverse of the Generalized Extreme Value distribution function
 
  CALL:  x = wgevinv(F,k,s,m)
 
         x = inverse cdf for the GEV distribution evaluated at F
         k = shape parameter in the GEV 
         s = scale parameter in the GEV, s>0  (default 1)
         m = location parameter in the GEV    (default 0)
 
 
  The Generalized Extreme Value distribution is defined by its cdf
 
                 exp( - (1 - k(x-m)/s)^1/k) ),  k~=0
   F(x;k,s,m) =
                 exp( -exp(-(x-m)/s) ),  k==0
 
   for x>s/k+m (when k<=0) and x<m+s/k (when k>0).
 
  Example:
    F = linspace(0,1,100);
    x = wgevinv(F,0.8,2,11);
    plot(F,x)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function x = wgevinv(F,k,s,m)
002 %WGEVINV Inverse of the Generalized Extreme Value distribution function
003 %
004 % CALL:  x = wgevinv(F,k,s,m)
005 %
006 %        x = inverse cdf for the GEV distribution evaluated at F
007 %        k = shape parameter in the GEV 
008 %        s = scale parameter in the GEV, s>0  (default 1)
009 %        m = location parameter in the GEV    (default 0)
010 %
011 %
012 % The Generalized Extreme Value distribution is defined by its cdf
013 %
014 %                exp( - (1 - k(x-m)/s)^1/k) ),  k~=0
015 %  F(x;k,s,m) =
016 %                exp( -exp(-(x-m)/s) ),  k==0
017 %
018 %  for x>s/k+m (when k<=0) and x<m+s/k (when k>0).
019 %
020 % Example:
021 %   F = linspace(0,1,100);
022 %   x = wgevinv(F,0.8,2,11);
023 %   plot(F,x)
024 
025 % References 
026 %  Johnson  N.L., Kotz S. and Balakrishnan, N. (1994)
027 %  Continuous Univariate Distributions, Volume 1. Wiley. 
028 
029 % Tested on: Matlab 5.3
030 % History: 
031 % Revised by jr 22.12.1999
032 % revised ms 14.06.2000
033 % - updated header info
034 % - changed name to wgevinv (from gevinv)
035 % revised pab 24.10.2000
036 % - added  nargchk, comnsize and default values for m, s
037 
038 error(nargchk(2,4,nargin))
039 if nargin<3,  s=1;end
040 if nargin<4,  m=0;end
041 [errorcode F k,s,m] = comnsize(F,k,s,m);
042 if errorcode > 0
043     error('k s and m must be of common size or scalar.');
044 end
045 
046 % Initialize  x to zero.
047 x = zeros(size(k));
048 
049 epsilon=1e-4;
050 
051 ok = (F>=0 & F<=1 & s>0);
052 
053 k1 = find(abs(k)< epsilon & ok);
054 if any(k1)
055   x(k1) = m(k1) - s(k1).*log(-log(F(k1)));
056 end
057 
058 k2 = find(abs(k)>= epsilon & ok);
059 if any(k2)
060   x(k2) = m(k2) + s(k2).*(1-(-log(F(k2))).^k(k2))./k(k2);
061 end
062 
063 
064 tmp=Inf;
065 k3 = find(abs(k) < epsilon & F==1&ok);
066 if any(k3)
067   x(k3)=tmp(ones(size(k3)));
068 end
069 k4 = find(abs(k) >= epsilon & F==1&ok);
070 if any(k4)
071   x(k4)=m(k4)+s(k4)./k(k4);
072 end
073 
074 k5=find(F==0&ok);
075 if any(k5),
076   x(k5)=-tmp(ones(size(k5)));
077 end
078 
079 k6=find(~ok);
080 if any(k6),
081   tmp=NaN;
082   x(k6)=tmp(ones(size(k6)));
083 end
084 
085 
086 
087

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