7

I have a function containing: Independent variable X, Dependent variable Y
Two fixed parameters a and b.

Using identical experimental data, both the curve_fit and leastsq functions could be fitted to the function with similar results.

Using curve_fit I have: [ 2.50110215e-04 , 7.80730380e-05] for fixed parameters a and b.

Using leastsq I have: [ 2.50110267e-04 , 7.80730843e-05] for fixed parameters a and b.

I would like to know if are there any differences in both of them, if so, what are the what situations should I use curve_fit and what situation should I use leastsq?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
user3208105
  • 71
  • 1
  • 4

1 Answers1

6

curve-fit is using leastsq for the calculation, so they should always give the same result. The miniscule difference you see there is probably a result of rounding error somewhere. calling leastsq directly should eliminate that.

From the docs of curve_fit:

The algorithm uses the Levenberg-Marquardt algorithm through leastsq. Additional keyword arguments are passed directly to that algorithm.

M4rtini
  • 13,186
  • 4
  • 35
  • 42