Home > wafo > wstats > wgpdrnd.m

wgpdrnd

PURPOSE

Random matrices from a Generalized Pareto Distribution

SYNOPSIS

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

DESCRIPTION

``` WGPDRND Random matrices from a Generalized Pareto Distribution

CALL:  R = wgpdrnd(k,s,m,sz);

R = matrix of random numbers
k = shape parameter in the GPD  (see wgpdcdf)
s = scale parameter in the GPD    (default 1)
m = location parameter in the GPD (default 0)
sz = size(R)    (Default common size of k, s and m)
sz can be a comma separated list or a vector
giving the size of R (see zeros for options).

The random numbers are generated by the inverse method.

Example:
R1=wgpdrnd(2,1,0,1,100);  % GPD k=2
R2=wgpdrnd(1,1,0,1,100);  % GPD k=1  ==>  Uniform
R3=wgpdrnd(0,1,0,1,100);  % GPD k=0  ==>  Exponential
plot([R1 R2 R3],'.')

CROSS-REFERENCE INFORMATION

This function calls:
 comnsize Check if all input arguments are either scalar or of common size. wgpdinv Inverse of the Generalized Pareto distribution function error Display message and abort function.
This function is called by:
 Chapter5 % CHAPTER5 contains the commands used in Chapter 5 of the tutorial test_cycles Quick test of the routines in module 'cycles' tpextrapolate Extrapolates a sequence of turning points.

SOURCE CODE

```001 function r = wgpdrnd(k,s,m0,varargin);
002 %WGPDRND Random matrices from a Generalized Pareto Distribution
003 %
004 % CALL:  R = wgpdrnd(k,s,m,sz);
005 %
006 %        R = matrix of random numbers
007 %        k = shape parameter in the GPD  (see wgpdcdf)
008 %        s = scale parameter in the GPD    (default 1)
009 %        m = location parameter in the GPD (default 0)
010 %        sz = size(R)    (Default common size of k, s and m)
011 %             sz can be a comma separated list or a vector
012 %             giving the size of R (see zeros for options).
013 %
014 % The random numbers are generated by the inverse method.
015 %
016 % Example:
017 %   R1=wgpdrnd(2,1,0,1,100);  % GPD k=2
018 %   R2=wgpdrnd(1,1,0,1,100);  % GPD k=1  ==>  Uniform
019 %   R3=wgpdrnd(0,1,0,1,100);  % GPD k=0  ==>  Exponential
020 %   plot([R1 R2 R3],'.')
021 %
023
024 % Tested on: Matlab 5.3
025 % History:
026 % Revised by jr 22.12.1999
027 % revised ms 14.06.2000
028 % - updated header info
029 % - changed name to wgpdrnd (from gpdrnd)
030 % - allowed 2 arguments
031 % revised pab 23.10.2000
032 %   - added default s,m0
033 %  - added comnsize, nargchk
034 %  - added greater flexibility on the sizing of R
035
036 error(nargchk(2,inf,nargin))
037 if nargin<2|isempty(s), s=1;end
038 if nargin<3|isempty(m0), m0=0;end
039 if nargin<4,
040   [errorcode k ,s,m0] = comnsize(k,s,m0);
041 else
042   [errorcode k,s,m0] = comnsize(k,s,m0,zeros(varargin{:}));
043 end
044 if errorcode > 0
045   error('k,s and m0 must be of common size or scalar.');
046 end
047 r = wgpdinv(rand(size(k)),k,s,m0);
048
049```

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