Home > wafo > wstats > wgevrnd.m

wgevrnd

PURPOSE ^

Random matrices from a Generalized Extreme Value distribution

SYNOPSIS ^

r = wgevrnd(k,s,m0,varargin);

DESCRIPTION ^

 WGEVRND Random matrices from a Generalized Extreme Value distribution
  
  CALL:  R = wgevrnd(k,s,m0,sz)
      
         R = matrix of random numbers
         k = shape parameter in the GEV
         s = scale parameter in the GEV, s>0  (default 1)
        m0 = location parameter in the GEV    (default 0)
        sz = size(R)    (Default common size of k,s and m0)
             sz can be a comma separated list or a vector 
             giving the size of R (see zeros for options). 
  
  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).
 
  The random numbers are generated by the inverse method. 
 
  Example:
    R1=wgevrnd(0.5,5,0,1,100);  % Finite end-point (R1<4)
    plot(R1,'.')
    R2=wgevrnd(0,2,0,1,100);    % Gumbel
    plot(R2,'.')
    R3=wgevrnd(-.5,.2,0,1,100); % Heavy tailed
    plot(R3,'.')
 
  See also  wgevinv, zeros

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function r = wgevrnd(k,s,m0,varargin);
002 %WGEVRND Random matrices from a Generalized Extreme Value distribution
003 % 
004 % CALL:  R = wgevrnd(k,s,m0,sz)
005 %     
006 %        R = matrix of random numbers
007 %        k = shape parameter in the GEV
008 %        s = scale parameter in the GEV, s>0  (default 1)
009 %       m0 = location parameter in the GEV    (default 0)
010 %       sz = size(R)    (Default common size of k,s and m0)
011 %            sz can be a comma separated list or a vector 
012 %            giving the size of R (see zeros for options). 
013 % 
014 % The generalized extreme-value distribution is defined by its cdf
015 %
016 %                exp( - (1 - k(x-m)/s))^1/k) ),  k~=0
017 %  F(x;k,s,m) =
018 %                exp( -exp(-(x-m)/s) ),  k==0
019 %
020 %  for x>s/k+m (when k<=0) and x<m+s/k (when k>0).
021 %
022 % The random numbers are generated by the inverse method. 
023 %
024 % Example:
025 %   R1=wgevrnd(0.5,5,0,1,100);  % Finite end-point (R1<4)
026 %   plot(R1,'.')
027 %   R2=wgevrnd(0,2,0,1,100);    % Gumbel
028 %   plot(R2,'.')
029 %   R3=wgevrnd(-.5,.2,0,1,100); % Heavy tailed
030 %   plot(R3,'.')
031 %
032 % See also  wgevinv, zeros
033 
034 
035 % Tested on: Matlab 5.3
036 % History: 
037 % Revised by jr 22.12.1999
038 % revised ms 14.06.2000
039 % - updated header info
040 % - changed name to wgevrnd (from gevrnd)
041 % - allowed 3 arguments
042 % revised pab 23.10.2000
043 %   - added default s,m0
044 %  - added comnsize, nargchk
045 %  - added greater flexibility on the sizing of R
046 
047 error(nargchk(2,inf,nargin))
048 if nargin<2|isempty(s), s=1;end
049 if nargin<3|isempty(m0), m0=0;end
050 
051 if nargin<4,
052   [errorcode k ,s,m0] = comnsize(k,s,m0);
053 else
054   [errorcode k,s,m0] = comnsize(k,s,m0,zeros(varargin{:}));
055 end
056 if errorcode > 0
057   error('k,s and m0 must be of common size or scalar.');
058 end
059   
060 r = wgevinv(rand(size(k)),k,s,m0);
061 
062

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