Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia finding multiple argmin

Tags:

min

julia

I have been trying to find the multiple argmin of the list, and on the explanation part it declares that "If there are multiple minimal elements, then the first one will be returned."

For example,

x=[1,-1,-1,2]
argmin(x)

It only returned 2. However, I would like to get 2,3. Is there any possible way to fix it?

like image 392
Tan Sheng-rong Tan Avatar asked Apr 21 '20 20:04

Tan Sheng-rong Tan


1 Answers

No, you have to find that manually with findall:

findall(==(minimum(x)), x)

Note that this is efficient, it will not call minimum more than once. The expression ==(minimum(x)) defines a function.

like image 74
Michael K. Borregaard Avatar answered Nov 01 '22 22:11

Michael K. Borregaard