- Are you just trying to get numerical estimates or do you need to derive some equations (I'm wondering why you are using symbolics)?
- If you just want estimates, why do you prefer the method of moments over maximum likelihood? Since you have sample data values, you could use ML, which is generally better.
solve 3 parameter weibull using method of moments - integral with parameters inside a solve
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Lauren Arendse
il 19 Feb 2019
Commentato: Lauren Arendse
il 21 Feb 2019
Hi all,
I am trying to use the method of moment to solve the 3 parameters of the weibull distribution. I have input all the equations however the intergal function embedded gives me an output error. I am not sure how to embed the integral into the solve function. I.e. the integral is complaining that is has a variable and not a value. Here is a link to the euqations for the moments.
Error using integral (line 85): A and B must be floating-point scalars.
Error in MOM>@(n)integral(@(s)fun(s,n),0,n)
Error in MOM (line 21) : eqn=[c +
(a*(g(1+1/b)))==u,a*sqrt(g(1+2/b)-(g(1+1/b))^2)==var,(g(1+3/b)-3*g(1+1/b)*g(1+2/b)+2*(g(1+1/b))^3)/((g(1+2/b)-(g(1+1/b))^2)^1.5)==skew;]
note I use 'name' cause i have multiply files which I would need to apply this too.
name=strcat('Location_',num2str(p,'%02d'),'_hs.mat');
load(name);
u=nanmean(values);
var=std(values);
skew=skewness(values);
s=values;
syms a b c
fun=@(s,n) s.^(n-1).*exp(-s); %integal of the gamma function
g=@(n) integral(@(s)fun(s,n),0,n); %gamma funtion
eqn=[c + (a*(g(1+1/b)))==u,a*sqrt(g(1+2/b)-(g(1+1/b))^2)==var,(g(1+3/b)-3*g(1+1/b)*g(1+2/b)+2*(g(1+1/b))^3)/((g(1+2/b)-(g(1+1/b))^2)^1.5)==skew;]
vars=[a b c];
[sola, solb, solc]=solve(eqn, vars)
5 Commenti
Risposta accettata
Jeff Miller
il 20 Feb 2019
Lauren,
If you just want to get numerical estimates, Cupid will give them to you. Here is a script for that:
load('Location_01_hs.mat');
xbar = mean(values)
xvar = var(values)
cenmom3 = mean( (values-xbar).^3 ) % Cupid moment estimation uses the 3rd central moment
weib = Weibull(2,2,1); % Just guess some starting parameter values
weib.EstMom([xbar, xvar, cenmom3]) % This is the command for moment estimation
weib.Mean % Check the mean, variance, and 3rd moment with the estimated parameter values.
weib.Variance % These should match the values computed from data.
weib.CenMoment(3)
Here is the output:
xbar =
3.2147
xvar =
2.5325
cenmom3 =
5.3489
ans =
Weibull(2.2442,1.3118,1.1457)
ans =
3.2147
ans =
2.5325
ans =
5.3489
2 Commenti
Jan
il 21 Feb 2019
You can simply download the toolbox from the given link: https://github.com/milleratotago/Cupid
Più risposte (1)
Lauren Arendse
il 21 Feb 2019
4 Commenti
Jan
il 21 Feb 2019
@Lauren: Please explain this in detail. Are you sure that an admin of MathWorks has asked you to set a flag instead of using teh standard methods of voting or accepting the working answer? You have accepted another answer, which marks it as a working solution. Using a flag to post a comment would be a rather tedious option, because there is a number of users and admin who control the flags frequently, because this is the only method to get attention, if somebody is rude or posts illegal contents.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!