Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我在为样本熵编写 python 代码时遇到的问题。
map(max, abs(a[i]-a) )很慢。
map(max, abs(a[i]-a) )
有没有其他功能比 性能更好map()?
map()
a看起来像的ndarray在哪里np.array([ [1,2,3,4,5],[2,3,4,5,6],[3,4,5,3,2] ])
a
np.array([ [1,2,3,4,5],[2,3,4,5,6],[3,4,5,3,2] ])
使用矢量化最大值
>>> map(max, abs(a[2]-a) ) [3, 4, 0] >>> np.abs(a[2] - a).max(axis=1) array([3, 4, 0])