0

The scipy function scipy.optimize import curve_fit can fit 1D functions and returns popt (Optimal values for the parameters) and pcov (the estimated covariance of popt).

There are also packages to fit multidimensional functions like sklearn (see this post). However there is no estimated covariance for the parameters.

Is there any way to get the parameters and the corresponding errors with python?

Example code:

x = ...
y = ...

def f(x, a, b, c, d, e):
    return a*x[0] + b*x[1] + c*x[2] + d*x[3] + e*x[4]

fit = fit(f, x, y)
Oliver Wilken
  • 2,654
  • 1
  • 24
  • 34
  • Perhaps [this](https://lmfit.github.io/lmfit-py/)? – DavidG Jul 21 '17 at 09:28
  • @DavidG I don't understand how they do the multidimensional fitting. They say: "The fitting routines accept data arrays that are one dimensional and double precision. So you need to convert the data and model to be one dimensional. A simple way to do this is to use numpy.ndarray.flatten" For me that sounds as if multidimensional fitting is not possible with lmfit – Oliver Wilken Jul 21 '17 at 09:43
  • It might not be. I'm no expert using lmfit but just thought I should post it incase it was useful, seems like it isn't. – DavidG Jul 21 '17 at 09:44
  • 1
    yes thank you for your post. The topic "How can I fit multi-dimensional data?" obviously is missleading – Oliver Wilken Jul 21 '17 at 10:03

0 Answers0