# How to use maximum likelihood estimation (mle) if the custom function has an integration inside?

4 views (last 30 days)
sun on 18 Jun 2021
Edited: sun on 22 Jun 2021
Dear friends,
First of all, thanks so much in advance to read my question. I already typed all the equations or code.
Q: I am trying to verify the estimation resource (link below) results. In other words, if the code is right
my code is not working, but I am not sure where is the problem. If possible, please give me some hint.
PDF = @(x,beta,a,n) beta.*((x./a).^n).*(int((x./a).^n,u,0,t)).^(beat-1).*exp(-(int((x./a).^n,u,0,t))).^beta ;
syms t
x(t)= piecewise(0<=t<250,2, 250<=t<350,3, 350<=t<370,4, 370<=t<380,5, 380<=t<390,6, 390<=t<=inf,7 );
opt = statset('MaxIter',1e4,'MaxFunEvals',1e4,'FunValCheck','off','UseParallel',true);
ans=mle(x,'pdf',PDF,'start',[1,1,1],'Options',opt,'LowerBound',[1,1,1],'UpperBound',[4,4,4]);
So, the pdf and data are all here. but custom pdf has Integration inside, and the input data is 2D under piecewise function.
Once again, thanks so much for your help and time. I will reply your comments as quick as possible.

Sulaymon Eshkabilov on 20 Jun 2021
There are a few potential errs in your code:
(1) Typo: the variable in PDF expression beat has to be beta > Still some work is left to correct the expression here.
(2) In line two: syms t has to be: syms x(t)
(3) Numerical values of x(t) needs to be computed within [0, 1e5] or something like that. Not up to inf to get some numerical values.
(4) Numerical values of x(t) can be obtained with fplot, e.g.: X = fplot(x, [0, 1e3]);
(5) The computed X needs to be plugged into: ans
##### 1 CommentShowHide None
sun on 20 Jun 2021
Edited: sun on 22 Jun 2021
thanks.