WGUMBINV Inverse of the Gumbel distribution function. CALL: x = wgumbinv(F,a,b,trunc) x = Inverse Gumbel evaluated at F a, b = parameters of the Gumbel distribution. trunc = 0 regular gumbel distribution (default) 1 truncated gumbel distribution Gumbel cdf is given by : F(x) = exp(-exp(-(x-b)/a) -inf < x < inf, a>0 or the truncated F(x) = [exp(-exp(-(x-b)/a)) -exp(-exp(b/a)) ]/(1-exp(-exp(b/a))) 0 < x < inf, a>0 Example: F = linspace(0,1,100); x1 = wgumbinv(F,2,0); x2 = wgumbinv(F,1,1); plot(F,x1,F,x2) See also wgumbfit, wgumbrnd, wgumbpdf, wgumbinv, wgumbstat, wgumbplot
Check if all input arguments are either scalar or of common size. | |
Display message and abort function. | |
Infinity. | |
Not-a-Number. |
Random matrices from a Gumbel distribution. |
001 function x = wgumbinv(F,a,b,trunc) 002 %WGUMBINV Inverse of the Gumbel distribution function. 003 % 004 % CALL: x = wgumbinv(F,a,b,trunc) 005 % 006 % x = Inverse Gumbel evaluated at F 007 % a, b = parameters of the Gumbel distribution. 008 % trunc = 0 regular gumbel distribution (default) 009 % 1 truncated gumbel distribution 010 % 011 % Gumbel cdf is given by : 012 % F(x) = exp(-exp(-(x-b)/a) -inf < x < inf, a>0 013 % or the truncated 014 % F(x) = [exp(-exp(-(x-b)/a)) -exp(-exp(b/a)) ]/(1-exp(-exp(b/a))) 015 % 0 < x < inf, a>0 016 % 017 % Example: 018 % F = linspace(0,1,100); 019 % x1 = wgumbinv(F,2,0); x2 = wgumbinv(F,1,1); 020 % plot(F,x1,F,x2) 021 % 022 % See also wgumbfit, wgumbrnd, wgumbpdf, wgumbinv, wgumbstat, wgumbplot 023 024 % Reference: 025 % Johnson N.L., Kotz S. and Balakrishnan, N. (1994) 026 % Continuous Univariate Distributions, Volume 2. Wiley. 027 028 029 % tested on: matlab 5.2 030 % history 031 % revised pab 8.11.1999 032 % updated header info 033 % Per A. Brodtkorb 17.10.98 034 % rewritten ms 19.06.2000 035 % revised pab 25.10.2000 036 % - added nargchk+comnsize 037 038 error(nargchk(3,4,nargin)) 039 if nargin<4|isempty(trunc), trunc=0;end 040 041 [errorcode F a b] = comnsize(F,a,b); 042 if errorcode > 0 043 error('F, a and b must be of common size or scalar.'); 044 end 045 x=zeros(size(F)); 046 047 ok = (0<=F& F<=1 & a>0); 048 049 k1=find((F>0)&(F<1) & ok); 050 051 if any(k1) 052 if trunc, 053 tmp=exp(-exp(b(k1)./a(k1))); 054 x(k1) =-a(k1).* log(-log((1-tmp).* F(k1) +tmp) ) + b(k1); 055 else 056 x(k1) =-a(k1).* log(-log( F(k1)) ) + b(k1); 057 end 058 end 059 tmp=Inf; 060 k2=find(F==0 & ok); 061 if any(k2) 062 if trunc 063 x(k2)=zeros(size(k2)); 064 else 065 x(k2)=-tmp(ones(size(k2))); 066 end 067 end 068 k3=find(F==1& ok); 069 if any(k3) 070 x(k3)=tmp(ones(size(k3))); 071 end 072 073 k4= find(~ok); 074 if any(k4) 075 x(k4)=NaN; 076 end 077
Comments or corrections to the WAFO group