'Why does optimize,leastsq work and optimize.least_squares not?
I'm trying to fit my experimental data to a theoretical model. I used to do it with scipy.optimize.leastsq, but sometimes I would get negative temperature. Since I find no way to limit the parameter space using this function, I moved to using what I understood to be a newer version of the same thing, scipy.optimize.least_squares. However, with this function I never get a fit, even though they both fit the same expression. Any idea why could that be and how to solve it?
p2 , success = sp.optimize.leastsq(errfunc, p0, args=(Voltage, Average),maxfev=800) #the fitting is minimizing said difference
p2 = sp.optimize.least_squares(errfunc, p0, args=(Voltage, Average),bounds=([0,0,-100,0,-np.inf,-np.inf,-np.inf,0],[0.005,np.inf,100,np.inf,np.inf,100,np.inf,0.005]),max_nfev=800) #the fitting is minimizing said difference
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
