I'm trying to use optimization.curve_fit to find the least square solution between two arrays, but I keep getting error: Result from function call is not a proper array of floats. I pasted my code below. Any ideas how to fix this? Thank you!
import numpy as np
import scipy.optimize as optimization
pcone = np.array([[-0.01043151],
[-0.00135030],
[-0.02566969],
[-0.02822495],
[-0.05463625],
[-0.00969918],
[-0.01332421],
[-0.03364439],
[-0.04009642],
[-0.03556982]])
pctwo = np.array([[0.02550008],
[0.04422852],
[0.06685288],
[0.04751296],
[0.02439405],
[0.09654185],
[0.03161849],
[0.03834721],
[0.01653997],
[-0.00802414]])
def func(x, a, b, c):
return a + b*x + c*x*x
print optimization.curve_fit(func, pcone, pctwo)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…