min

min(x: array, /, *, axis: int | Tuple[int, ...] | None = None, keepdims: bool = False) array

Calculates the minimum value of the input array x.

Parameters:
  • x (array) – input array. Should have a real-valued data type.

  • axis (Optional[Union[int, Tuple[int, ...]]]) – axis or axes along which to compute minimum values. By default, the minimum value must be computed over the entire array. If a tuple of integers, minimum values must be computed over multiple axes. A valid axis must be an integer on the interval [-N, N), where N is the number of axes in x. If an axis is specified as a negative integer, the function must determine the axis along which to perform the operation by counting backward from the last axis (where -1 refers to the last axis). If provided an invalid axis, the function must raise an exception. Default: None.

  • keepdims (bool) – if True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see Broadcasting). Otherwise, if False, the reduced axes (dimensions) must not be included in the result. Default: False.

Returns:

out (array) – if the minimum value is computed over the entire array, a zero-dimensional array containing the minimum value; otherwise, a non-zero-dimensional array containing the minimum values. The returned array must have the same data type as x.

Notes

  • When the number of elements over which to compute the minimum value is zero, the minimum value is implementation-defined. Specification-compliant libraries may choose to raise an error, return a sentinel value (e.g., if x is a floating-point input array, return NaN), or return the maximum possible value for the input array x data type (e.g., if x is a floating-point array, return +infinity).

  • The order of signed zeros is unspecified and thus implementation-defined. When choosing between -0 or +0 as a minimum value, specification-compliant libraries may choose to return either value.

  • For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-defined (see Complex Number Ordering).

Special Cases

For floating-point operands,

  • If x_i is NaN, the minimum value must be NaN (i.e., NaN values propagate).

Changed in version 2023.12: Clarified that the order of signed zeros is implementation-defined.