Home > wafo > wstats > wgumbfit.m

# wgumbfit

## PURPOSE

Parameter estimates for Gumbel data.

## SYNOPSIS

[phat, cov,pci] = wgumbfit(data1, plotflag)

## DESCRIPTION

``` WGUMBFIT Parameter estimates for Gumbel data.

CALL: [phat, cov] = wgumbfit(data,plotflag)

phat = the maximum likelihood estimates of the
parameters of the Gumbel distribution given the data.
cov  = asymptotic covariance matrix of estimates
data = data vector
plotflag = 0, do not plot
> 0, plot the empiricial distribution function and the
estimated cdf (see empdistr for options)(default)

Example:
R = wgumbrnd(1,2,1,100,1);
[phat, cov] = wgumbfit(R)

## CROSS-REFERENCE INFORMATION

This function calls:
 empdistr Computes and plots the empirical CDF wgumbcdf Gumbel cumulative distribution function. wnorminv Inverse of the Normal distribution function deblank Remove trailing blanks. error Display message and abort function. fzero Scalar nonlinear zero finding. mean Average or mean value. optimset Create/alter OPTIM OPTIONS structure. std Standard deviation. str2num Convert string matrix to numeric array. title Graph title. version MATLAB version number.
This function is called by:
 dist2dfit Parameter estimates for DIST2D data. mdist2dfit Parameter estimates for MDIST2D data.

## SOURCE CODE

```001 function [phat, cov,pci] = wgumbfit(data1, plotflag)
002 %WGUMBFIT Parameter estimates for Gumbel data.
003 %
004 % CALL: [phat, cov] = wgumbfit(data,plotflag)
005 %
006 %     phat = the maximum likelihood estimates of the
007 %            parameters of the Gumbel distribution given the data.
008 %     cov  = asymptotic covariance matrix of estimates
009 %     data = data vector
010 % plotflag = 0, do not plot
011 %          > 0, plot the empiricial distribution function and the
012 %               estimated cdf (see empdistr for options)(default)
013 %
014 % Example:
015 %   R = wgumbrnd(1,2,1,100,1);
016 %   [phat, cov] = wgumbfit(R)
017 %
019
020 % Reference:
021 %  Johnson  N.L., Kotz S. and Balakrishnan, N. (1994)
022 %  Continuous Univariate Distributions, Volume 2. Wiley.
023
024
025 % tested on: matlab 5.3
026 % rewritten ms 05.07.2000
027 % revised jr 01.09.2000
028 % - ahat and bhat were reversed in the covariance matrix.
029 % -revised pab added nargchk, pci + safer call to fzero
030 % - made sure data is  vector
031 % revised PJ 02-Apr-2001
032 %   Fixed problem with no or empty plotflag
033
034 error(nargchk(1,2,nargin))
035 if (nargin<2)|isempty(plotflag), plotflag=1; end
036 data=data1(:); % make sure it is a vector
037
038 start=6^(1/2)/pi*std(data) % Moment estimate of scale parameter a
039 mvrs=version;
040 ix=find(mvrs=='.');
041 if str2num(mvrs(1:ix(2)-1))>5.2,
042   ahat=fzero('wgumbafit',start,optimset,data);
043 else
044   ahat=fzero('wgumbafit',start,sqrt(eps),[],data);
045 end
046 bhat=-ahat*log(mean(exp(-data/ahat)));
047 phat=[ahat, bhat];
048
049 cov=[0.60793,0.25696;0.25696,1.10867]*ahat^2/length(data);
050 if nargout>2
051   alpha2 = ones(1,2)*0.05/2;
052   var = diag(cov).';
053   pci = wnorminv([alpha2;1-alpha2], [phat;phat],[var;var]);
054 end
055
056
057 if plotflag
058   sd=sort(data);
059   empdistr(sd,[sd wgumbcdf(sd,ahat,bhat)],plotflag)
060   title([deblank(['Empirical and Gumbel estimated cdf'])])
061 end
062
063
064```

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