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

 Madhavan Bomidi (03-28-19, 01:54 PM)
Hi,

I have x and y variables data arrays. These two variables are assumed to berelated 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 toobtain A and B for best fit.

Look forward to your suggestions and sample code as an example.

Thanks and regards,
 William Ray Wing (03-28-19, 04:51 PM)
> On Mar 28, 2019, at 7:54 AM, Madhavan Bomidi <blmadhavan> 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
[..]
 Madhavan Bomidi (03-28-19, 06:08 PM)
Hi Bill,

Thanks for your suggestion. Where am I actually using the curve_fit in the defined function func2fit? Don't I need to initial assumption of a, b and c values so that optimized convergence occur with iteration of the function for the input data of x?

Look forward to your suggestions,