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) See also wgumbplot, wgumbcdf, empdistr
Computes and plots the empirical CDF | |
Gumbel cumulative distribution function. | |
Inverse of the Normal distribution function | |
Remove trailing blanks. | |
Display message and abort function. | |
Scalar nonlinear zero finding. | |
Average or mean value. | |
Create/alter OPTIM OPTIONS structure. | |
Standard deviation. | |
Convert string matrix to numeric array. | |
Graph title. | |
MATLAB version number. |
Parameter estimates for DIST2D data. | |
Parameter estimates for MDIST2D data. |
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 % 018 % See also wgumbplot, wgumbcdf, empdistr 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
Comments or corrections to the WAFO group