WGPDINV Inverse of the Generalized Pareto distribution function CALL: x = wgpdinv(F,k,s,m) x = inverse cdf for the GPD evaluated at F k = shape parameter in the GPD s = scale parameter in the GPD (default 1) m = location parameter in the GPD (Default 0) The Generalized Pareto distribution is defined by its cdf 1 - (1-k(x-m)/s)^1/k, k~=0 F(x;k,s,m) = 1 - exp(-(x-m)/s), k==0 for x>m (when k<=0) and m<x<s/k (when k>0), s>0. Example: F = linspace(0,1,100); x = wgpdinv(F,0.3,2); plot(F,x) See also wgpdrnd, wgpdfit
Check if all input arguments are either scalar or of common size. | |
Display message and abort function. | |
Not-a-Number. |
Extrapolate level crossing spectrum | |
Random matrices from a Generalized Pareto Distribution |
001 function x = wgpdinv(F,k,s,m) 002 %WGPDINV Inverse of the Generalized Pareto distribution function 003 % 004 % CALL: x = wgpdinv(F,k,s,m) 005 % 006 % x = inverse cdf for the GPD evaluated at F 007 % k = shape parameter in the GPD 008 % s = scale parameter in the GPD (default 1) 009 % m = location parameter in the GPD (Default 0) 010 % 011 % The Generalized Pareto distribution is defined by its cdf 012 % 013 % 1 - (1-k(x-m)/s)^1/k, k~=0 014 % F(x;k,s,m) = 015 % 1 - exp(-(x-m)/s), k==0 016 % 017 % for x>m (when k<=0) and m<x<s/k (when k>0), s>0. 018 % 019 % Example: 020 % F = linspace(0,1,100); 021 % x = wgpdinv(F,0.3,2); 022 % plot(F,x) 023 % 024 % See also wgpdrnd, wgpdfit 025 026 % References 027 % Johnson N.L., Kotz S. and Balakrishnan, N. (1994) 028 % Continuous Univariate Distributions, Volume 1. Wiley. 029 030 % Tested on: Matlab 5.3 031 % History: 032 % Revised by jr 22.12.1999 033 % revised ms 14.06.2000 034 % - updated header info 035 % - changed name to wgpdinv (from gpdinv) 036 % revised pab 25.10.2000 037 % - adde nargchk + comnsize 038 error(nargchk(2,4,nargin)) 039 040 if nargin<4|isempty(m), m=0;end 041 if nargin<3|isempty(s), s=1;end 042 043 [errorcode F k s,m] = comnsize(F,k,s,m); 044 if errorcode > 0 045 error('x, k, s and m must be of common size or scalar.'); 046 end 047 048 epsilon=1e-4; 049 % Initialize x to zero. 050 x = zeros(size(k)); 051 052 epsilon=1e-4; 053 054 ok = (F>=0 & F<=1 & s>0); 055 056 k1 = find(abs(k)<= epsilon & ok); 057 if any(k1) 058 x(k1) = m(k1) - s(k1).*log(1-F(k1)); 059 end 060 061 k2 = find(abs(k)> epsilon & ok); 062 if any(k2) 063 x(k2) = m(k2) + s(k2).*(1-(1-F(k2)).^k(k2))./k(k2); 064 end 065 066 k6=find(~ok); 067 if any(k6), 068 tmp=NaN; 069 x(k6)=tmp(ones(size(k6))); 070 end 071
Comments or corrections to the WAFO group