NumPy:同时进行 max() 和 min() 的函数 [英] NumPy: function for simultaneous max() and min()

查看:30
本文介绍了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 中是否有一个函数可以只通过一次数据就找到最大值和最小值?

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

推荐答案

numpy API 中是否有一个函数可以只通过一次数据就找到最大值和最小值?

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天全站免登陆