Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a numpy "max minus min" function?

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

like image 523
Michel Keijzers Avatar asked Feb 16 '12 14:02

Michel Keijzers


1 Answers

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

like image 65
Sven Marnach Avatar answered Sep 29 '22 12:09

Sven Marnach