numpy.ptp¶

numpy.
ptp
(a, axis=None, out=None, keepdims=<no value>)[source]¶ Range of values (maximum  minimum) along an axis.
The name of the function comes from the acronym for ‘peak to peak’.
 Parameters
 aarray_like
Input values.
 axisNone or int or tuple of ints, optional
Axis along which to find the peaks. By default, flatten the array. axis may be negative, in which case it counts from the last to the first axis.
New in version 1.15.0.
If this is a tuple of ints, a reduction is performed on multiple axes, instead of a single axis or all the axes as before.
 outarray_like
Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type of the output values will be cast if necessary.
 keepdimsbool, optional
If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
If the default value is passed, then keepdims will not be passed through to the
ptp
method of subclasses ofndarray
, however any nondefault value will be. If the subclass’ method does not implement keepdims any exceptions will be raised.
 Returns
 ptpndarray
A new array holding the result, unless out was specified, in which case a reference to out is returned.
Examples
>>> x = np.arange(4).reshape((2,2)) >>> x array([[0, 1], [2, 3]])
>>> np.ptp(x, axis=0) array([2, 2])
>>> np.ptp(x, axis=1) array([1, 1])