如何将 3d 直方图的边缘值转换为直方图的中点值?
How to convert edge-values of a 3d histogram into mid-point values of the histogram?
如果 hist, (x, y, z) = numpy.histogramdd()
给出位置 (x、y、z) 对应于三维函数的 bin 的 edges,如何计算(内插)midpoints[=22= 处的直方图值] 即 (x+d/2, y+d/2, z+d/2) 其中 d 是 bin 在所有三个方向上的固定大小?
实际上,np.histogramdd
为您提供 x, y, z
中的 bin 边界,但计数是 "at the midpoints",而不是边界(严格来说它们都不是,它们超过了 d x d x d
以中点为中心的立方体)。
如果---出于某种原因---你在边界处有值并且想要插值并且如果你对线性插值没问题:
np.lib.stride_tricks.as_strided(hist, (2, 2, 2, *map((-1).__add__, hist.shape)), 2 * hist.strides).mean(axis=(0, 1, 2))
这只是取最近的 8 个邻居的平均值。
如果 hist, (x, y, z) = numpy.histogramdd()
给出位置 (x、y、z) 对应于三维函数的 bin 的 edges,如何计算(内插)midpoints[=22= 处的直方图值] 即 (x+d/2, y+d/2, z+d/2) 其中 d 是 bin 在所有三个方向上的固定大小?
实际上,np.histogramdd
为您提供 x, y, z
中的 bin 边界,但计数是 "at the midpoints",而不是边界(严格来说它们都不是,它们超过了 d x d x d
以中点为中心的立方体)。
如果---出于某种原因---你在边界处有值并且想要插值并且如果你对线性插值没问题:
np.lib.stride_tricks.as_strided(hist, (2, 2, 2, *map((-1).__add__, hist.shape)), 2 * hist.strides).mean(axis=(0, 1, 2))
这只是取最近的 8 个邻居的平均值。