Home > wafo > wstats > wgumbpdf.m

# wgumbpdf

## PURPOSE

Gumbel probability density function.

## SYNOPSIS

f = wgumbpdf(x,a,b,trunc)

## DESCRIPTION

``` WGUMBPDF Gumbel probability density function.

CALL:  f = wgumbpdf(x,a,b,trunc)

f    = Gumbel pdf evaluated at x
a, b  = parameters of the Gumbel distribution.
trunc = 0  regular gumbel distribution (default)
1  truncated gumbel distribution

Gumbel PDF  is given by :
f(x) = exp(-(x-b)/a)*exp(-exp(-(x-b)/a))/a    -inf < x < inf, a>0
or the truncated
f(x) = exp(-(x-b)/a)*exp(-exp(-(x-b)/a))/a/(1-exp(-exp(b/a)))
0 < x < inf, a>0

Example:
x = linspace(-4,8,200);
p1 = wgumbpdf(x,2,0); p2 = wgumbpdf(x,1,1);
plot(x,p1,x,p2)

## CROSS-REFERENCE INFORMATION

This function calls:
 comnsize Check if all input arguments are either scalar or of common size. error Display message and abort function. nan Not-a-Number.
This function is called by:
 dist2dfun is an internal function to dist2dcdf dist2dprb. dist2dpdf Joint 2D PDF computed as f(x1|X2=x2)*f(x2) mdist2dpdf Joint 2D PDF due to Plackett given as f{x1}*f{x2}*G(x1,x2;Psi).

## SOURCE CODE

```001 function f = wgumbpdf(x,a,b,trunc)
002 %WGUMBPDF Gumbel probability density function.
003 %
004 % CALL:  f = wgumbpdf(x,a,b,trunc)
005 %
006 %   f    = Gumbel pdf evaluated at x
007 %  a, b  = parameters of the Gumbel distribution.
008 %  trunc = 0  regular gumbel distribution (default)
009 %          1  truncated gumbel distribution
010 %
011 %  Gumbel PDF  is given by :
012 %      f(x) = exp(-(x-b)/a)*exp(-exp(-(x-b)/a))/a    -inf < x < inf, a>0
013 %  or the truncated
014 %      f(x) = exp(-(x-b)/a)*exp(-exp(-(x-b)/a))/a/(1-exp(-exp(b/a)))
015 %          0 < x < inf, a>0
016 %
017 % Example:
018 %   x = linspace(-4,8,200);
019 %   p1 = wgumbpdf(x,2,0); p2 = wgumbpdf(x,1,1);
020 %   plot(x,p1,x,p2)
021 %
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 24.10.2000
032 % - reimplemented comnsize
033 % revised pab 8.11.1999
035 %   Per A. Brodtkorb 17.10.98
036
037 error(nargchk(3,4,nargin))
038 if nargin < 4 | isempty(trunc),
039     trunc=0; % default value is not truncated
040 end
041
042 [errorcode x a b] = comnsize(x,a,b);
043 if errorcode > 0
044     error('x, a and b must be of common size or scalar.');
045 end
046
047 f = zeros(size(x));
048
049
050 if trunc,
051   k = find(x > 0 & a>0);
052 else
053   k = find(a>0);
054 end
055
056 if any(k),
057   tmp=exp(-(x(k) -b(k))./a(k)  );
058   f(k) =  tmp.* exp(-tmp)./a(k);
059   if trunc,
060     f(k)=f(k)./(1-exp(-exp(b(k)./a(k)  )));
061   end
062 end
063
064 k1 = find(a <= 0 );
065 if any(k1)
066    tmp   = NaN;
067    f(k1) = tmp(ones(size(k1)));
068 end
069```

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