
From:  Patrick Alken 
Subject:  Re: [Helpgsl] Nonlinear LeastSquares Fitting 
Date:  Thu, 11 Jan 2018 09:44:31 0700 
Useragent:  Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 
Hello,Yes this is a bug, thanks for reporting it. The problem was I had defined the time variable to be in [0, N], where N is the number of points to fit. Then, for some values of N, after the first iteration the solver finds a negative value for lambda, and so exp(lambda * N) gets very large, resulting in nan values in the expb_f function.
I have now replaced the time variable with: t_i = i * TMAX / (N  1)so that t \in [0,TMAX] and you can increase N to anything you want. I left TMAX = 40. I will update the example program in the repository. In the meantime I have attached the corrected source code. I tested it up to N = 1000. Please let me know if you have any further problems.
Thanks, Patrick On 01/11/2018 04:50 AM, Anna Russo Russo wrote:
Hi! I've run the "Exponential Fitting Example", from the GSL 2.4 documentation, and I noticed that, if the number of data points is greater than 56, the solver terminates with status "exceeded max number of iterations". It happens even if I allow it to perform a considerably larger number of iterations: after the first iteration the parameters are so different from the right ones that the value of the function to be minimized is 'nan' and they don't change in the next iterations. What may be the cause for this behavior? Thanks for reading, Anna
nlfit.c
Description: Text Data
[Prev in Thread]  Current Thread  [Next in Thread] 