Re: non-linear regression update.

Let me see...

1. chi_pre is undefined the first time around.

2. The improvement test looks fishy.  Shouldn't it be "- DELTA/2"?

3. You use the same DELTA for several different things.  The one
   you use for numeric differentiation might be problematic for
   cases where the parameters themselves are small.  The root
   finder in Gnumeric uses something like abs(x/1e6) (for x!=0 and
   something else for x==0).

4. The algorithm definitely need to know the valid ranges for the
   parameters.  Suppose you wanted to fit with

      sqrt (a*x1*x1 + b*x2*x2)

   You then need to make sure that a>0 and b>0.  The current algorithm
   could wander outside this areas and would then bail out even though
   a smaller step might have kept it inside the proper area.

5. "for (count = 0; count < MAX_STEPS; cout++)": use count, not cout...

6. "par = tmp_par;" -- this is pointer assignement.  I bet you meant
   to assign all elements.

7. "derivative" actually changes params.  I don't think that is a good
   idea, at least not without restoring.

8. More or less all the error cases leak memory.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]