Minimizing one variable function with different parameters, time-efficient solution

5 visualizaciones (últimos 30 días)
Hello,
I want to minimize a one variable function f(x) for different values of one parameter a. I found this solution:
function y=f(x,a)
y=abs(phi(x))+(x-a).^2; % phi is a differentiable function
end
-----------------
eps=0.2
for i=1:size(a,1)
xmin=fminbnd(@(x)f(x,a(i)),a(i)-eps,a(i)+eps); % we know the minimum is close to a
end
Vector a has more than 450000 values, so it takes an unacceptable computation time. Do you think there exists another more time-efficient solution?
Thank you in advance
  1 comentario
Babak
Babak el 24 de Sept. de 2012
Are you looking to find xmin which is the same size as a?
In other words, xmin in your for loop is over-writing itself.
My understanding from your question is that you are looking for a curve of xmin(a) that for different values of a, gives you minimum values of the function g(x) = f(x,a). Am I right?

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 30 de Sept. de 2012
Do you expect xmin(i) to be close to xmin(i-1)? If so, you could do
eps=0.2;
xmin=nan(size(a)); %pre-allocate
xmin(1)=fminbnd(@(x)f(x,a(1)),a(1)-eps,a(1)+eps); %initialize
for i=2:size(a,1)
xmin(i)=fminsearch(@(x)f(x,a(i)),xmin(i-1));
end

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by