我有二维数据,并且有一堆用 生成的二维箱scipy.stats.binned_statistic_2d
。对于每个数据点,我想要它占用的 bin 的索引。这正是np.digitize
是用于,但据我所知,它只处理一维数据。Thisstackexchange 似乎有一个答案,但这完全推广到 n 维。对于二维有更直接的解决方案吗?
您已经可以从第四个返回变量中获取每个观察值的 bin 索引scipy.stats.binned_statistic_2d:
Returns:
statistic : (nx, ny) ndarray
The values of the selected statistic in each two-dimensional bin.
xedges : (nx + 1) ndarray
The bin edges along the first dimension.
yedges : (ny + 1) ndarray
The bin edges along the second dimension.
binnumber : (N,) array of ints or (2,N) ndarray of ints
This assigns to each element of sample an integer that
represents the bin in which this observation falls. The
representation depends on the expand_binnumbers argument.
See Notes for details.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)