<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Computing argmax fast in Python</title>
	<link>http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/</link>
	<description>Daniel Lemire's blog is about life in academia, research in Computer Science, wondering how we can reconcile fast databases and algorithms with the informal and asemantic nature of the world around us. It is broadcasted from  Montreal (Canada).</description>
	<pubDate>Thu, 28 Aug 2008 22:53:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>

	<item>
		<title>By: Protector one</title>
		<link>http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-49905</link>
		<author>Protector one</author>
		<pubDate>Wed, 07 May 2008 20:31:05 +0000</pubDate>
		<guid>http://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-49905</guid>
		<description>I'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://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-49710</link>
		<author>SwiftCoder</author>
		<pubDate>Tue, 29 Jan 2008 14:20:38 +0000</pubDate>
		<guid>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 - 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://www.daniel-lemire.com/blog/archives/2004/11/25/computing-argmax-fast-in-python/#comment-1219</link>
		<author>Anonymous</author>
		<pubDate>Sun, 13 Feb 2005 14:16:10 +0000</pubDate>
		<guid>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>
