Home > wafo > wstats > wexpfit.m

wexpfit

PURPOSE ^

Parameter estimates for Exponential data.

SYNOPSIS ^

[phat, var,pCI] = wexpfit(data,plotflag)

DESCRIPTION ^

 WEXPFIT Parameter estimates for Exponential data.
 
  CALL: [bhat var] = wexpfit(data, plotflag)
 
     mhat  = maximum likelihood estimate of the parameter of
             the distribution (see wexppdf)
     var   = estimated asymptotic variance of mhat
     data  = data matrix
  plotflag = 0, do not plot
           > 0, plot the empiricial distribution function and the
                estimated cdf (see empdistr for options)(default)
 
  Example:
    R=wexprnd(2,100,1);
    [mhat var]=wexpfit(R,1)
    R=wexprnd(2,100,3);
    [mhat var]=wexpfit(R,3)
 
  See also  empdistr

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [phat, var,pCI] = wexpfit(data,plotflag)
002 %WEXPFIT Parameter estimates for Exponential data.
003 %
004 % CALL: [bhat var] = wexpfit(data, plotflag)
005 %
006 %    mhat  = maximum likelihood estimate of the parameter of
007 %            the distribution (see wexppdf)
008 %    var   = estimated asymptotic variance of mhat
009 %    data  = data matrix
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=wexprnd(2,100,1);
016 %   [mhat var]=wexpfit(R,1)
017 %   R=wexprnd(2,100,3);
018 %   [mhat var]=wexpfit(R,3)
019 %
020 % See also  empdistr
021 
022 % Reference: Johnson, Kotz and Balakrishnan (1994)
023 % "Continuous Univariate Distributions, vol. 1", p. 494 ff
024 % Wiley
025 
026 
027 %tested on: matlab 5.x
028 % History:
029 % revised pab 24.10.2000
030 % - added  nargchk + 95% CI for phat
031 % - fixed some bugs when data is a matrix 
032 % added ms 16.08.2000
033 
034 error(nargchk(1,2,nargin))
035 if nargin<2|isempty(plotflag),  plotflag=1; end
036 sz = size(data);
037 Nsz=length(sz);
038 dim = min(find(sz~=1));  %1st non-singleton dimension
039 % make sure dim=1 is the first non-singleton dimension
040 if isempty(dim) | dim ~= 1, 
041   order = [dim 1:dim-1 dim+1:Nsz];
042   data  = permute(data,order);
043   sz    = size(data);
044 end
045 m = prod(sz(2:end));
046 n =sz(1);
047 
048 phat=mean(data);
049 
050 var=phat.^2/n;
051 if nargout>2, % phat ~ gamma(n,phat/n)
052   alpha2=0.05/2;
053   pCI = [wgaminv(alpha2,n,phat/n);wgaminv(1 - alpha2,n,phat/n)];
054 end
055 if  plotflag
056   sd=sort(data);
057   empdistr(sd(:,1),[sd(:,1) wexpcdf(sd(:,1),phat(1))],plotflag), hold on
058   for ix=2:m,empdistr(sd(:,ix),[sd(:,ix) wexpcdf(sd(:,ix),phat(ix))],plotflag),end
059   hold off
060   title([deblank(['Empirical and Exponential estimated cdf'])])
061 end
062 
063 
064 
065 
066 
067 
068

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