numpy:同时用于max()和min()的函数 [英] numpy: function for simultaneous max() and min()

查看:164
本文介绍了numpy:同时用于max()和min()的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

numpy.amax()将在数组中找到最大值,然后 numpy.amin( )对最小值进行相同的操作.如果我想同时找到max和min,则必须调用这两个函数,这需要将(非常大的)数组传递两次,这似乎很慢.

numpy.amax() will find the max value in an array, and numpy.amin() does the same for the min value. If I want to find both max and min, I have to call both functions, which requires passing over the (very big) array twice, which seems slow.

numpy API中是否有一个函数可以只通过一次数据就可以找到max和min?

Is there a function in the numpy API that finds both max and min with only a single pass through the data?

推荐答案

numpy API中是否有一个函数可以只通过一次数据就可以找到max和min?

Is there a function in the numpy API that finds both max and min with only a single pass through the data?

不.在撰写本文时,尚无此功能. (是的,如果有 这样的函数,则其性能将比在大型数组上依次调用numpy.amin()numpy.amax()的性能显着 .)

No. At the time of this writing, there is no such function. (And yes, if there were such a function, its performance would be significantly better than calling numpy.amin() and numpy.amax() successively on a large array.)

这篇关于numpy:同时用于max()和min()的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆