[Numpy-discussion] unclear output format for numpy.argmax()

Todd toddrjen@gmail....
Tue Mar 12 02:48:36 CDT 2013


On Tue, Mar 12, 2013 at 8:20 AM, soumen ganguly
<soumendotganguly@gmail.com>wrote:

> Hello,
>
> There are some doubts that i have regarding the argmax() method of
> numpy.As described in reference doc's of numpy,argmax(axis=None,out=None)
> returns the indices of the maximum value along the given axis(In this case
> 0 is default).
>
> So, i tried to implement the method to a 2d array with elements
> say,[[1,2,3],[4,5,6]] along the axis 1.The output to this code is [2,2] and
> when i implement it along the axis 0,it outputs [1,1,1].I dont see the
> connection to this output with the scope of argmax method.
>
> I would appreciate a detailed insight to the argmax method.
>
>
I am not sure I understand the question.  For axis 0 (the "outer" dimension
in the way it is printed) the things being compared are argmax([1, 4]),
argmax(([2, 5]), and argmax([3, 6])..  Amongst those, the second (index 1)
is higher in each case, so it returns [1, 1, 1].  With axis 1 (the "inner"
dimension in the way it is printed) , the things being compared are
argmax([1, 2, 3]) and argmax([4, 5, 6]).  In both case the third (index 2)
is the highest, so it returns [2, 2].  What is unexpected about this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130312/d6b65653/attachment.html 


More information about the NumPy-Discussion mailing list