<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Computing argmax fast in Python</title>
	<atom:link href="http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/</link>
	<description>Computer Scientist and Open Scholar: Databases, Information Retrieval, Business Intelligence.</description>
	<lastBuildDate>Mon, 14 May 2012 12:14:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: argmax in Python &#124; Tastalian&#039;s Blog</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-55219</link>
		<dc:creator>argmax in Python &#124; Tastalian&#039;s Blog</dc:creator>
		<pubDate>Tue, 24 Apr 2012 22:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-55219</guid>
		<description>[...] called the &#8220;argmax&#8221; of (f) on (C). One can find solutions for this on-line, e.g. in this blog post, but I realized recently that Python&#8217;s max() function can actually handle the job. Here is [...]</description>
		<content:encoded><![CDATA[<p>[...] called the &#8220;argmax&#8221; of (f) on (C). One can find solutions for this on-line, e.g. in this blog post, but I realized recently that Python&#8217;s max() function can actually handle the job. Here is [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-54357</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 27 Apr 2011 15:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-54357</guid>
		<description>How about

max(xrange(len(array)), key=array.__getitem__)</description>
		<content:encoded><![CDATA[<p>How about</p>
<p>max(xrange(len(array)), key=array.__getitem__)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mapio</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-54174</link>
		<dc:creator>Mapio</dc:creator>
		<pubDate>Sat, 29 Jan 2011 16:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-54174</guid>
		<description>In case of duplicate values you solution returns the last position, while the array.index(max(array)) solution returns the first which, beside the simplicity of the solution, seems to be the more natural answer.</description>
		<content:encoded><![CDATA[<p>In case of duplicate values you solution returns the last position, while the array.index(max(array)) solution returns the first which, beside the simplicity of the solution, seems to be the more natural answer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-50354</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Thu, 18 Dec 2008 13:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-50354</guid>
		<description>import numpy

array = numpy.array ( [1,2,4,3,5,1 ] )

numpy.argmax( array )

# should return 4</description>
		<content:encoded><![CDATA[<p>import numpy</p>
<p>array = numpy.array ( [1,2,4,3,5,1 ] )</p>
<p>numpy.argmax( array )</p>
<p># should return 4</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fast argmax in Python</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-50350</link>
		<dc:creator>Fast argmax in Python</dc:creator>
		<pubDate>Wed, 17 Dec 2008 13:48:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-50350</guid>
		<description>[...] my post Computing argmax fast in Python, I reported that Python has no builtin function to compute argmax, the position of a maximal value. [...]</description>
		<content:encoded><![CDATA[<p>[...] my post Computing argmax fast in Python, I reported that Python has no builtin function to compute argmax, the position of a maximal value. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kralin</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-50349</link>
		<dc:creator>kralin</dc:creator>
		<pubDate>Wed, 17 Dec 2008 11:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-50349</guid>
		<description>array.index(max(array))

is it too simple?</description>
		<content:encoded><![CDATA[<p>array.index(max(array))</p>
<p>is it too simple?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Protector one</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-49905</link>
		<dc:creator>Protector one</dc:creator>
		<pubDate>Wed, 07 May 2008 20:31:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-49905</guid>
		<description>I&#039;m sorry SwiftCoder, but I believe that is a max. It is equivalent to:

  m = max(array)

My (arg)max:

  lambda array: max([array[i],i] for i in range(len(array)))[1]

Cheers!</description>
		<content:encoded><![CDATA[<p>I&#8217;m sorry SwiftCoder, but I believe that is a max. It is equivalent to:</p>
<p>  m = max(array)</p>
<p>My (arg)max:</p>
<p>  lambda array: max([array[i],i] for i in range(len(array)))[1]</p>
<p>Cheers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SwiftCoder</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-49710</link>
		<dc:creator>SwiftCoder</dc:creator>
		<pubDate>Tue, 29 Jan 2008 14:20:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-49710</guid>
		<description>You should also try a functional idiom - typically better and faster:

array = [1.0, 2.0, 3.0, 1.0]

m = reduce(max, array)</description>
		<content:encoded><![CDATA[<p>You should also try a functional idiom &#8211; typically better and faster:</p>
<p>array = [1.0, 2.0, 3.0, 1.0]</p>
<p>m = reduce(max, array)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://lemire.me/blog/archives/2004/11/25/computing-argmax-fast-in-python/comment-page-1/#comment-1219</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sun, 13 Feb 2005 14:16:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-1219</guid>
		<description>You can try this:

def positionMax(sequence, excludedIndexesSet=None):
    if not badindexes:
        return max(  izip(sequence, xrange(len(sequence)) )  )[1]
    else:
        badindexes = set(badindexes)
        return max( (e,i) for i,e in enumerate(sequence) if i not in badindexes )[1]</description>
		<content:encoded><![CDATA[<p>You can try this:</p>
<p>def positionMax(sequence, excludedIndexesSet=None):<br />
    if not badindexes:<br />
        return max(  izip(sequence, xrange(len(sequence)) )  )[1]<br />
    else:<br />
        badindexes = set(badindexes)<br />
        return max( (e,i) for i,e in enumerate(sequence) if i not in badindexes )[1]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

