Thursday, November 4, 2010

Python max index numpy.argmax(asarray(

So in Matlab I loved how I could do:

[A I]=max(Array)

And get I the index of the maximum value. To do this in sage (python) I finally ended up with this command:


Where Array is my python list, I have to use asarray() to convert it to a numpy array. Then the argmax returns the first occurrence of the maximum.

No comments: