我正在尝试使用计算高斯二维分布的峰值位置,ndimage.measurements.center_of_mass
并发现质心从峰值中心偏移:
import numpy as np
from scipy import ndimage
from scipy import stats
import matplotlib.pyplot as plt
x = np.linspace(-1,1,100)
xv, yv = np.meshgrid(x, x)
r = np.sqrt((xv-0.2)**2 + (yv)**2)
norm2d = stats.norm.pdf(r)
com = ndimage.measurements.center_of_mass(norm2d)
plt.imshow(norm2d, origin="lower")
plt.scatter(*com[::-1])
plt.show()
如何在不使用最小二乘优化例程的情况下粗略计算嘈杂的二维高斯分布的峰值位置?