是否有一个numpy max min函数? [英] Is there a numpy max min function?

查看:69
本文介绍了是否有一个numpy max min函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个numpy函数为给定的numpy数组提供最大值-最小值,即numpy.max(a)-numpy.min(a)?

Is there a numpy function that gives for a given numpy array its maximum - minimum value, i.e. numpy.max(a) - numpy.min(a) ?

例如

numpy.xxx([4,3,2, 6] = 4 since max = 6, min = 2, 6 - 4 = 2)

原因:由于max和min会导致数组迭代次数增加两倍(在我的情况下为750万个或更多),因此性能提高.

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).

推荐答案

确实有这样的功能-它叫做

Indeed there is such a function -- it's called numpy.ptp() for "peak to peak".

这篇关于是否有一个numpy max min函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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