Levenberg-Marquardt non-linear least-squares fitting in Python

William Ray Wing wrw at mac.com
Thu Mar 28 10:51:39 EDT 2019



> On Mar 28, 2019, at 7:54 AM, Madhavan Bomidi <blmadhavan at gmail.com> wrote:
> 
> Hi,
> 
> I have x and y variables data arrays. These two variables are assumed to be related as y = A * exp(x/B). Now, I wanted to use Levenberg-Marquardt non-linear least-squares fitting to find A and B for the best fit of the data. Can anyone suggest me how I can proceed with the same. My intention is to obtain A and B for best fit.
> 

Have you looked at the non-linear least-squares solutions in scicpy?
Specifically, a system I’ve had to solve several times in the past uses it and it works quite well.

from scipy.optimize import curve_fit

def func2fit(x,a,b,c):
    return a - b * np.exp(-c * x)    

Bill

> Look forward to your suggestions and sample code as an example.
> 
> Thanks and regards,
> Madhavan
> -- 
> https://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list