是否有一个 numpy 的“最大减最小”?功能?
是否有一个 numpy 函数可以为给定的 numpy 数组提供其最大值 - 最小值,即 numpy.max(a) - numpy.min(a) ?
例如
numpy.xxx([4,3,2, 6] = 4 since max = 6, min = 2, 6 - 4 = 2)
原因:性能提高,因为 max 和 min 会导致数组迭代两次(在我的例子中是 750 万或更多数字)。
Is there a numpy function that gives for a given numpy array its maximum - minimum value, i.e. numpy.max(a) - numpy.min(a) ?
e.g.
numpy.xxx([4,3,2, 6] = 4 since max = 6, min = 2, 6 - 4 = 2)
Reason: performance increase since max and min would cause twice the iteration of the array (which is in my case 7.5 million or more numbers).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确实有这样一个函数——它被称为
numpy。 ptp()
表示“峰峰值”。Indeed there is such a function -- it's called
numpy.ptp()
for "peak to peak".