【发布时间】:2015-06-26 10:15:36
【问题描述】:
我必须对大量数据 (5 000 000) 使用 curve_fit numpy 函数。 所以基本上我已经创建了一个二维数组。第一个维度是要执行的拟合数,第二个维度是用于拟合的点数。
t = np.array([0 1 2 3 4])
for d in np.ndindex(data.shape[0]):
try:
popt, pcov = curve_fit(func, t, np.squeeze(data[d,:]), p0=[1000,100])
except RuntimeError:
print("Error - curve_fit failed")
多处理可以用来加速整个过程,但它仍然很慢。 有没有办法以“矢量化”的方式使用curve_fit?
【问题讨论】:
-
有可能使用 Python 的
multiprocessing内置模块。 This answer 应该能帮到你
标签: python performance numpy curve-fitting