numpy.minimum

numpy.minimum(x1, x2[, out])

Element-wise minimum of array elements.

Compare two arrays and returns a new array containing the element-wise minima.

Parameters:

x1, x2 : array_like

The arrays holding the elements to be compared.

Returns:

y : {ndarray, scalar}

The minimum of x1 and x2, element-wise. Returns scalar if both x1 and x2 are scalars.

See also

maximum
element-wise maximum

Notes

Equivalent to np.where(x1 < x2, x1, x2) but faster and does proper broadcasting.

Examples

>>> np.minimum([2, 3, 4], [1, 5, 2])
array([1, 3, 2])
>>> np.minimum(np.eye(2), [0.5, 2])
array([[ 0.5,  0. ],
       [ 0. ,  1. ]])

Previous topic

numpy.maximum

Next topic

numpy.nan_to_num

This Page

Quick search