Home > wafo > wstats > wgumbstat.m

# wgumbstat

## PURPOSE

Mean and variance for the Gumbel distribution.

## SYNOPSIS

[m,v]= wgumbstat(a,b,trunc);

## DESCRIPTION

``` WGUMBSTAT Mean and variance for the Gumbel distribution.

CALL:  [m,v] = wgumbstat(a,b,trunc)

m, v = the mean and variance, respectively
a, b = parameters of the Gumbel distribution (see wgumbcdf)
trunc = 0  regular gumbel distribution (default)
1  truncated gumbel distribution (not available)

Mean (m) and variance (v) for the Gumbel distribution is

m=Euler*a+b  and  v=(a*pi)^2/6  where Euler is Euler's
constant 0.5772...

Example:
X = wgumbrnd(5,10,[],1000,1);
[mean(X) var(X)]        % Estimated mean and variance
[m,v] = wgumbstat(5,10) % True mean and variance

## 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:
 dist2dcdf Joint 2D CDF computed as int F(X1 dist2dstat Mean and variance for the DIST2D distribution mdist2dstat Mean and variance for the MDIST2D distribution.

## SOURCE CODE

```001 function [m,v]= wgumbstat(a,b,trunc);
002 %WGUMBSTAT Mean and variance for the Gumbel distribution.
003 %
004 % CALL:  [m,v] = wgumbstat(a,b,trunc)
005 %
006 %   m, v = the mean and variance, respectively
007 %   a, b = parameters of the Gumbel distribution (see wgumbcdf)
008 %  trunc = 0  regular gumbel distribution (default)
009 %          1  truncated gumbel distribution (not available)
010 %
011 %  Mean (m) and variance (v) for the Gumbel distribution is
012 %
013 %  m=Euler*a+b  and  v=(a*pi)^2/6  where Euler is Euler's
014 %  constant 0.5772...
015 %
016 % Example:
017 %   X = wgumbrnd(5,10,[],1000,1);
018 %   [mean(X) var(X)]        % Estimated mean and variance
019 %   [m,v] = wgumbstat(5,10) % True mean and variance
020 %
022
023 % Reference:
024 %  Johnson  N.L., Kotz S. and Balakrishnan, N. (1994)
025 %  Continuous Univariate Distributions, Volume 2. Wiley.
026
027
028 %  tested on: matlab 5.2
029 % history
030 % revised pab 8.11.1999
032 %   Per A. Brodtkorb 17.10.98
033 % revised ms 14.06.2000
034 % - changed name to wgumbstat (from gumbstat)
035 % - revised header info
036 % - noted that calculations are wrong for trunc=1 (not corrected)
037
038 error(nargchk(2,3,nargin))
039
040 [errorcode a b] = comnsize(a,b);
041 if errorcode > 0,
042   error('a and b  must be of common size or scalar.');
043 end
044 if nargin < 3 | isempty(trunc),
045     trunc=0; % default value is not truncated
046 end
047
048
049 m = 0.5772*a+b; %mean
050 v = pi^2/6*a.^2; %variance
051
052 if trunc, %This is not correct (ms)
053   tmp=1-exp(-exp( b./a));
054   m=m./tmp;
055   v=v./tmp;
056 end
057 % Return NaN if A is negative or zero.
058 k = find(a <= 0);
059 if any(k)
060     tmp = NaN;
061     m(k) = tmp(ones(size(k)));
062     v(k) = m(k);
063 end
064
065```

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