I am programming a physics simulation (Ising model, if it matters) and I need to fit an 1D decaying exponential function to a set of data and have an estimation of the parameters of the function but however I have searched I cannot for the life of me understand the different fitting methods and choose one that can accomplish this seemingly non-complex task. I have a program in Python that uses scipy.optimization.curve_fit for this function but due to the simulation requiring enormous computing time I am trying to switch to C++.

1 Answer 1


scipy.optimize.curve_fit uses the lm method by default for unconstrained problems. The documentation for scipy.optimize.least_squares says that

Method ‘lm’ (Levenberg-Marquardt) calls a wrapper over least-squares algorithms implemented in MINPACK (lmder, lmdif).

MINPACK is a Fortran library, but there seems to be a C/C++ version as well: C/C++ Minpack.

Then there are some projects mentioned in the Eigen documentation, foremost the Ceres Solver.

If C is an option, the GNU Scientific Library (GSL) provides linear and non-linear least squares functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.