[Numpy-discussion] Indices of min/max element of an array?

Perry Greenfield perry at stsci.edu
Tue Dec 6 09:16:16 EST 2005

Why not:

ind = where(arr == arr.max())

and use the first element of the index array(s)

Perry Greenfield

On Dec 6, 2005, at 12:06 PM, Christos Siopis wrote:

> Hi all,
> I was wondering if i'm missing a numpy/numarray function that would 
> return the
> indices of the minimum/maximum element of an array. Argmin/max can 
> only do this
> one axis at a time. Alternatively, one can find the index for the 
> flattened array
> and then play with modulo arithmetic, which gets quickly annoying for 
> > 2
> dimensions. Since this is a rather frequent operation, i would think 
> there's
> already a function for it?...
> Thanks,
> Christos
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log 
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list