ptp(a, axis=None, out=None, keepdims=False)¶
Range of values (maximum - minimum) along an axis.
LAX-backend implementation of
ptp(). Original docstring below.
The name of the function comes from the acronym for ‘peak to peak’.
a (array_like) – Input values.
out (array_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.
keepdims (bool, 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.
ptp – A new array holding the result, unless out was specified, in which case a reference to out is returned.
- Return type
>>> 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])