fminbnd loop leads to same optimizer

1 vue (au cours des 30 derniers jours)
alpedhuez
alpedhuez le 3 Août 2020
Commenté : alpedhuez le 4 Août 2020
I have a matrix of parameter A that is 2*2 matrix and other matrix B. The solution matrix C that is 2*1
Then I run
for i=1:1:2
C(i,1)=fminbnd(@(b) fun(A(i,1),A(i,2),b,B),0,1)
end
Then strangely, even when paramters A(1,:) and A(2,:) are very different, I got the same optimizer. For example, A is
0.870639815937867 0.845094090200317
0.748241117938819 0.400000548158531
C is
0.150263993746969
0.150256643269687
This happens multiple times. What is going on? Can it be that first run of fminbnd affects the second run of fminbnd?
  4 commentaires
John D'Errico
John D'Errico le 3 Août 2020
The crystal ball is so foggy today. It simply will not show me the contents of your computer, to tell us what the function fun does. It just keeps on telling me that you will soon come into a large sum of money. Or maybe that means I will come into some money. Whatever. ONE of us will be getting righ soon. Maybe. Should I try my deck of MATLAB tarot cards instead? Tea leaves? :)
If you really want help, then you need to show us the function fun.
alpedhuez
alpedhuez le 3 Août 2020
Yes you wrote fminsearchbnd so I will appreciate if you take a look at the attached mix file. If one run this script for, let me say, 15 times, then one will encounter a case where the solutions of the optimization problems are the same even though the paramters are different. I wlll appreciate comments.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 3 Août 2020
Modifié(e) : Matt J le 3 Août 2020
In addition to hwat John said, you could plot the function to confirm whether fminbnd is giving you a good approximation of the minimizer in each case. If it is, that will tell you that it is not fminbnd's fault. The minimizer is simply not as sensitive a function of A as you had believed.
I would note that there is clearly some impact that A is having on the output. The successive C(i) that you have showed are similar, but not identical.
  15 commentaires
Matt J
Matt J le 4 Août 2020
If the break point is not reached, it may be because an if-else-end statement sent the code along a different path...
alpedhuez
alpedhuez le 4 Août 2020
Let me work on it.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by