argmin
result = argmin(x, [on_invalid=])
Input: x, on_invalid · Output: result
What it is
0-based index of the first-occurring minimum/maximum element of x (a scalar, Vec, or Mat/Signal, flattened).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = argmin(x, [on_invalid=]) | x scalar, Vec, Mat, or Signal0-based index of the first-occurring minimum/maximum element of x (a scalar, Vec, or Mat/Signal, flattened).on_invalid optionalon_invalid= ("propagate"/"ignore"/"error", see this section's intro) controls NaN/Inf handling. | on_invalid= —"propagate"/"ignore"/"error", see this section's introx —or, under axis=, the original row/column | Returns a scalar Num index. on_invalid= ("propagate"/"ignore"/"error", see this section's intro) controls NaN/Inf handling; under "ignore" the returned index still refers to a position in the original, unfiltered x (or, under axis=, the original row/column), so it can be used to index straight back into the caller's own data. On a Mat, the optional axis= keyword (0 or 1) instead returns the index of the extremum *within* each column or row — a Vec of length cols/rows, each entry an index into that column/row rather than into the flattened matrix. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
y = [5, 2, 9, 1, 1, 9]
print("argmin(y) = {argmin(y)}, argmax(y) = {argmax(y)}") # 3, 2 (first tie wins)
output
argmin(y) = 3, argmax(y) = 2
from fundamentals
See also
argmax — documented in the same entry.