Fitting a 3D array of data to a 1D function with numpy or scipy
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 4I am currently trying to fit a lot of data to a sine function. In the case where I only have one set of data (1D array), scipy.optimize.curve_fit() works fine. However it does not permit a higher dimensional data input if the function itself is only one dimensional as far as i can see. I don't want to iterate over the array using for loops as that works incredibly slow in python. My code so far should look similar to this: from scipy import optimize import numpy as np def f(x,p1,p2,p3,p4): return p1 + p2*np.sin(2*np.pi*p3*x + p4) #fit