what is this mean: Gradient must be provided for trust-region algorithm?
Mostrar comentarios más antiguos
Hi,
I have matlab code, when I run it I receive this message:
Warning: Gradient must be provided for trust-region algorithm; using line-search algorithm instead. > In fminunc at 367 In false_alarm_detection_2 at 14
Local minimum found.
Optimization completed because the size of the gradient is less than the selected value of the function tolerance.
what is that mean? and how can be solved?
Thanks
1 comentario
Sean de Wolski
el 24 de Mayo de 2013
It means the default algorithm isn't suitable for the way you've called fminunc. You can just ignore the warning, it picked a different algorithm instead.
Respuesta aceptada
Más respuestas (1)
FMINUNC seems like overkill for a 1D root finding problem. Why not just use FZERO?
xv = fzero(@(x) gammainc(5,x)- vall(i) ,4);
6 comentarios
Sean de Wolski
el 24 de Mayo de 2013
Editada: Sean de Wolski
el 24 de Mayo de 2013
@Matt, I suggested FMINUNC in Jamal's other thread because fzero can overstep and pass a negative value into gammainc. This throws an error.
OK, but then, why not use FMINBND? Or, if you don't know an upper bound, you could do something like this
xv = fzero(@(z) gammainc(5,z.^2)- vall(i) , 2).^2;
Alan Weiss
el 24 de Mayo de 2013
Editada: Alan Weiss
el 24 de Mayo de 2013
gammainc(5,x) is a monotone decreasing function with value 1 at x=0 and value 0 at x=Inf. Jamal wants to find a value of x so that gammainc(5,x) = gamma(5)*10^0 = 24. This is impossible. It is also not possible for gamma(5)*5*10^-1 or gamma(5)*10^-1 or gamma(5)*5*10^-2.
For values y such that 0 < y < 1, it is not hard to find a value x so that gammainc(5,x) = y:
x = fzero(@(x)gammainc(5,x)-y,[0,100]);
Why? Because
gammainc(5,100) = 5.9919e-91
This is close enough to 0 for all practical purposes, and fzero will not try to step outside the initial interval [0,100].
Alan Weiss
MATLAB mathematical toolbox documentation
Jamal Ahmad
el 26 de Mayo de 2013
Editada: Matt J
el 27 de Mayo de 2013
Jamal Ahmad
el 26 de Mayo de 2013
Editada: Matt J
el 27 de Mayo de 2013
so, after gammainc(5,6.982) the result will be between 0.24 and 1
Yes, but your target values of gammainc are not between 0.24 and 1. Here is the stream of vall(i) that your code produces
vall =
0.0024 0.0120 0.0240 0.1200 0.2400 1.2000 2.4000 12.0000 24.0000
As you can see, they exceed 1 for i>=6. As Alan said, it is not possible for gammainc(5,x) to reach a value greater than 1.
Categorías
Más información sobre Special Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!