📄 weibmom.m
字号:
function [bh,ah] = weibmom(x);
% Estimation of Weibull parameters using the
% method of moments.
[n1 n2] = size(x);
n = n1*n2;
x = reshape(x,n,1);
m1 = (1/n)*sum(x); % First moment
m2 = (1/n)*sum(x.^2); % Second moment
div = (m1^2)/m2;
% Generate gamma table
% See I. Olkin, L. J. Gleser, and C. Derman
% Probability Models and Applications
% Macmillan. p. 281.
z = 0:0.001:0.99;
table = ((gamma(1+z)).^2)./(gamma(1+2*z));
% Find closest value
tt = abs(div-table);
[val ind] = min(tt);
% Interpolate teh values in table
% using linear interpolation
if abs(div-table(ind+1)) > abs(div-table(ind-1))
xx = [z(ind) z(ind-1)];
yy = [table(ind) table(ind-1)];
else
xx = [z(ind) z(ind+1)];
yy = [table(ind) table(ind+1)];
end
penbe = polyfit(xx,yy,1);
bh = (div-penbe(2))/penbe(1);
bh = 1/bh;
% Compute the other parameter
ah = ((gamma(1+(1/bh)))^2/m1)^bh;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -