Home > wafo > wstats > wtraylfit.m

wtraylfit

PURPOSE ^

Parameter estimates for Truncated Rayleigh data.

SYNOPSIS ^

[phat,cov,pci] = wtraylfit(data,plotflag)

DESCRIPTION ^

 WTRAYLFIT Parameter estimates for Truncated Rayleigh data. 
  
  CALL:  [phat cov] = wtraylfit(data, plotflag) 
  
    phat  = maximum likelihood estimate of the parameter of 
            the distribution (see wtraylcdf) 
    cov   = estimated asymptotic covariance of phat 
    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=wraylrnd(2,200,1); 
    R=R(R>1)-1;   % Truncated Raylay with b=2, c=-1 
    [phat cov]=wtraylfit(R) 
  
  See also  wtraylcdf, wraylfit

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [phat,cov,pci] = wtraylfit(data,plotflag) 
002 %WTRAYLFIT Parameter estimates for Truncated Rayleigh data. 
003 % 
004 % CALL:  [phat cov] = wtraylfit(data, plotflag) 
005 % 
006 %   phat  = maximum likelihood estimate of the parameter of 
007 %           the distribution (see wtraylcdf) 
008 %   cov   = estimated asymptotic covariance of phat 
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=wraylrnd(2,200,1); 
016 %   R=R(R>1)-1;   % Truncated Raylay with b=2, c=-1 
017 %   [phat cov]=wtraylfit(R) 
018 % 
019 % See also  wtraylcdf, wraylfit 
020  
021 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability 
022 % and Life Span Models", p. 181 ff, Marcel Dekker. 
023  
024 %tested on: matlab 5.x 
025 % History: 
026 %  by Per A. Brodtkorb 17.10.98 
027 % revised ms 15.06.2000 
028 % - updated header info 
029 % - changed name to wraylfit (from raylfit) 
030 % revised ms 11.08.2000 
031 % - changed to standard *fit form 
032 % -revised pab 24.10.2000 
033 %  - replaced gamma with gammaln -> more robust 
034 %  - added nargchk 
035 % revised PJ 03-Apr-2001 
036 %  - fmins changed name to fminsearch for version >= 5.3 
037 % Revised pab Dec2003 
038  
039 error(nargchk(1,2,nargin)) 
040 if nargin<2|isempty(plotflag),  plotflag=1; end 
041 data = data(:); 
042 n = length(data); 
043 phat = sqrt(sum(data.^2)/n/2); % Initial guess (MLE with c=0) 
044  
045 mvrs=version;ix=find(mvrs=='.'); 
046 if str2num(mvrs(1:ix(2)-1))>5.2, 
047   phat = fminsearch('loglike', [phat 0],optimset,data,'wtraylpdf'); 
048 else 
049   phat = fmins('loglike', [phat 0],[],[],data,'wtraylpdf'); 
050 end 
051  
052 if nargout > 1 
053    [L, cov] = loglike(phat,data,'wtraylpdf'); 
054 end 
055  
056  
057 if nargout>2, 
058   var=diag(cov)'; 
059   alpha2=ones(1,2)*0.05/2; 
060   pci = wnorminv([alpha2;1-alpha2],[phat;phat],[var;var]); 
061 end 
062  
063 if plotflag  
064   sd = sort(data); 
065   empdistr(sd,[sd,wtraylcdf(sd,phat(1),phat(2))],plotflag ) 
066   title([deblank(['Empirical and truncated Rayleigh estimated cdf'])]) 
067 end 
068  
069  
070  
071

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