Least squares in a set of equations with optimize.leastsq() (Python)
问题 I have two functions and a set of data. Both functions have the same x data and the same parameters. I want to obtain the parameters by least squares method that makes the best fit of my data. The parameters are: ex,ey,ez. The X data are: RA,DE (like 3000 points). The Y data are: dRA,dDE. I tried this but I obtained a wrong solution: def residuals(p, dRA, dDE, RA, DEC): ex,ey,ez = p f1 = dRA-(ex*sin(DEC)*cos(RA)+ey*sin(DEC)*sin(RA)-ez*cos(DEC)) f2 = dDE-(-ex*sin(RA)+ey*cos(RA)) err = np