Minimizing one variable function with different parameters, time-efficient solution
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Babak
2012 年 9 月 24 日
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?
回答 (1 件)
Matt J
2012 年 9 月 30 日
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!