- bs = bs / 2;
- yaz_log(YLOG_LOG,"Fitting it=%d: a=%f / %f b=%f / %f chi = %f",
- it, a, as, b, bs, chi );
+ { // a,b is the best so far, adjust one step size
+ // which one? The one that has the greatest effect to chi
+ // That is, the average of plus and minus is further away from chi
+ double adif = 0.5 * ( aplus + aminus ) - prevchi;
+ double bdif = 0.5 * ( bplus + bminus ) - prevchi;
+ if ( fabs(adif) > fabs(bdif) )
+ {
+ as = as * ( 1.0 - stepchange);
+ branch = "step a";
+ }
+ else
+ {
+ bs = bs * ( 1.0 - stepchange);
+ branch = "step b";
+ }
+ }
+ yaz_log(YLOG_LOG,"Fitting %s it=%d: a=%g %g b=%g %g chi=%g ap=%g am=%g, bp=%g bm=%g p=%g",
+ branch, it, a, as, b, bs, chi,
+ aplus, aminus, bplus, bminus, prevchi );