numpy.amin() function is an alias for numpy.min() function.
NumPy amin()
The numpy.amin() function returns the minimum value in an array or the minimum value along a specified axis.
Syntax
</>
Copy
numpy.amin(a, axis=None, out=None, keepdims=False, initial=None, where=True)
Parameters
| Parameter | Type | Description |
|---|---|---|
a | array_like | Input array from which the minimum value is computed. |
axis | None, int, or tuple of ints, optional | Axis or axes along which to find the minimum. If None, the minimum of the flattened array is returned. |
out | ndarray, optional | Alternative output array to store the result. Must have the same shape as expected output. |
keepdims | bool, optional | If True, the reduced dimensions are kept as size one, allowing proper broadcasting. |
initial | scalar, optional | Specifies an initial minimum value for empty arrays. |
where | array_like of bool, optional | Specifies elements to include in the comparison for the minimum value. |
Return Value
Returns a scalar or an array containing the minimum values. If axis=None, a scalar value is returned. If axis is specified, an array with the reduced dimension is returned.
Examples
1. Finding the Minimum Value in an Array
This example demonstrates finding the smallest element in an array.
</>
Copy
import numpy as np
# Define an array
arr = np.array([3, 1, 4, 1, 5, 9, 2, 6])
# Find the minimum value
min_value = np.amin(arr)
# Print the result
print("Minimum value in the array:", min_value)
Output:
Minimum value in the array: 1
