我的目标是以尽可能最快的方式获得所有曲线的总和(这是一种具有位置依赖西格玛的高斯曲线的卷积)。
目前我的代码是:
sigs = get_sigmas(x0) # function that returns the value of sigma at each position
all_gauss_args = -0.5*np.power((x[:, np.newaxis] - x0[np.newaxis, :]) /
sigs[np.newaxis, :], 2.0)
sum = (1.0/(np.sqrt(2 * np.pi) * sigs[np.newaxis, :])) * np.exp(all_gauss_arg) *\
h[np.newaxis, :]
sum = np.sum(sum, axis=1)
return sum
可以加快速度吗?
提前感谢您的帮助