Asked by dert
on 13 Jan 2013

Hi, i'm trying to estimate the parameters of log likelihood function by using fminsearch. i have three parameters; x(1),x(2),x(3) and the set of valid parameters for x(1)-->[0,20] , for x(2)---> [0,1000], for x(3)---> [0,5000]. i want to find the estimated parameters in this set. So i have to add some conditions to fminsearch. Namely, to discourage the algorithm from finding local minumum outside the set of valid parameters, i have to define the log likelihood to be negative infinity for values outside this set. Then i have to restart the algorithm until no improvement could be found in 20 consecutive runs. But i don't know how to do this. Is this possible?? for fminsearch, my starting point x0:[20*rand,1000*rand,5000*rand]. Can anyone please help me??

*No products are associated with this question.*

Answer by Matt J
on 13 Jan 2013

It sounds like it should look something like this,

for i=1:20 [Xall(:,i),fval(i)]=fminsearch(...); end

[~,idx]=min(fval);

x=Xall(:,idx);

Answer by dert
on 15 Jan 2013

thank you for your helping. but i didnt understand so well because i havent been using matlab for a long time. Can you explain little bit?? how can i discourage to find outside the set of valid parameter?

Answer by Shashank Prasanna
on 15 Jan 2013

You are out of luck if you want to do this directly with FMINSEARCH since it does not allow for constraints. Your best options would be to reject all solutions where the constraints are violated (not in x(1)-->[0,20] , for x(2)---> [0,1000], for x(3)---> [0,5000]) and restart the optimization in a while loop.

If you do have the Optimization Toolbox this makes life much easier: I am assuming your objective function is smooth an continuous then you can say

fmincon(@loglikelihood_function,[20*rand,1000*rand,5000*rand],[],[],[],[],[0;0;0],[20;1000;5000],[],options)

From the fmincon doc http://www.mathworks.com/help/optim/ug/fmincon.html you can see that i specify the start point and constraints. The first argument is your likelihood function written out in MATLAB. the last option "options" is where you can specify when you want to stop the optimization, here is a list of all the options available: http://www.mathworks.com/help/optim/ug/optimization-options-reference.html

Also if you have the statistics toolbox just use MLE http://www.mathworks.com/help/stats/mle.html

Answer by Matt J
on 15 Jan 2013

You could also try transforming the variables so that they are fundamentally bounded, e.g. making the substitution

x(1)=10*sin(y(1))+10;

will ensure that x(1) is bounded to [0,20] even though you will be minimizing over y(1). However, your original post made it sound like you were asked to pursue an approach of setting the function to Inf in the appropriate places.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments