WBETAFIT Parameter estimates for Beta data. CALL: [phat, var] = wbetafit(data, plotflag) phat = [a,b] = the maximum likelihood estimates of the parameters of the beta 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=wbetarnd(2,2,1,100); phat = wbetafit(R,2) See also wbetacdf, empdistr
Computes and plots the empirical CDF | |
Log-likelihood function. | |
Beta cumulative distribution function | |
Inverse of the Normal distribution function | |
Remove trailing blanks. | |
Display message and abort function. | |
Multidimensional unconstrained nonlinear minimization (Nelder-Mead). | |
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 Beta-Rayleigh data. |
001 function [phat, cov,pci]=wbetafit(data1, plotflag); 002 %WBETAFIT Parameter estimates for Beta data. 003 % 004 % CALL: [phat, var] = wbetafit(data, plotflag) 005 % 006 % phat = [a,b] = the maximum likelihood estimates of the 007 % parameters of the beta distribution 008 % given the data. 009 % cov = asymptotic covariance matrix of estimates 010 % data = data vector 011 % plotflag = 0, do not plot 012 % > 0, plot the empiricial distribution function and the 013 % estimated cdf (see empdistr for options)(default) 014 % 015 % Example: 016 % R=wbetarnd(2,2,1,100); 017 % phat = wbetafit(R,2) 018 % 019 % See also wbetacdf, empdistr 020 021 % No Reference 022 % 023 024 % tested on: matlab 5.3 025 % History: 026 % By pab 24.10.2000 027 % revised PJ 03-Apr-2001 028 % - fmins changed name to fminsearch for version >= 5.3 029 030 031 error(nargchk(1,2,nargin)) 032 if any(data1<=0) 033 error('data must be strictly positive!') 034 end 035 if nargin<2|isempty(plotflag),plotflag=1;end 036 037 data=data1(:); % make sure it is a vector 038 039 mu = mean(data); 040 sa = std(data)^2; 041 042 % Supply a starting guess with method of moments: 043 a = (mu*(1-mu)/sa-1)*mu; 044 phat0 = [ a a*(1/mu-1)]; 045 046 mvrs=version;ix=find(mvrs=='.'); 047 if str2num(mvrs(1:ix(2)-1))>5.2, 048 phat = fminsearch('loglike',phat0,optimset,data,'wbetapdf'); 049 else 050 phat = fmins('loglike',phat0,[],[],data,'wbetapdf'); 051 end 052 053 if nargout>1, 054 [LL, cov] = loglike(phat,data,'wbetapdf'); 055 end 056 if nargout>2 057 alpha2 = ones(1,2)*0.05/2; 058 var = diag(cov).'; 059 pci = wnorminv([alpha2;1-alpha2], [phat;phat],[var;var]); 060 end 061 062 if plotflag 063 sd = sort(data); 064 empdistr(sd,[sd, wbetacdf(sd,phat(1),phat(2))],plotflag) 065 title([deblank(['Empirical and Beta estimated cdf'])]) 066 end 067
Comments or corrections to the WAFO group