<?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: Getting random documents from a CouchDB</title>
	<atom:link href="http://myrkur.de/thoughts/2009/05/17/random-documents-from-couchdb/feed/" rel="self" type="application/rss+xml" />
	<link>http://myrkur.de/thoughts/2009/05/17/random-documents-from-couchdb/</link>
	<description>And Chaos is good for you.</description>
	<lastBuildDate>Thu, 01 Jul 2010 04:50:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Xjs</title>
		<link>http://myrkur.de/thoughts/2009/05/17/random-documents-from-couchdb/comment-page-1/#comment-299</link>
		<dc:creator>Xjs</dc:creator>
		<pubDate>Thu, 01 Jul 2010 04:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://myrkur.de/thoughts/?p=110#comment-299</guid>
		<description>In fact, if the random numbers consistently aren&#039;t evenly distributed, this is an issue. But otherwise, due to the law of large numbers, everything will be fine as soon as we have some more than 4 documents. ;-)
The method could be perfected by writing a hash function optimized for even distribution. Perhaps one could use the _id-s, too, since they are in fact only numbers as well.</description>
		<content:encoded><![CDATA[<p>In fact, if the random numbers consistently aren&#8217;t evenly distributed, this is an issue. But otherwise, due to the law of large numbers, everything will be fine as soon as we have some more than 4 documents. <img src='http://myrkur.de/thoughts/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
The method could be perfected by writing a hash function optimized for even distribution. Perhaps one could use the _id-s, too, since they are in fact only numbers as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff M</title>
		<link>http://myrkur.de/thoughts/2009/05/17/random-documents-from-couchdb/comment-page-1/#comment-298</link>
		<dc:creator>Jeff M</dc:creator>
		<pubDate>Wed, 30 Jun 2010 22:26:47 +0000</pubDate>
		<guid isPermaLink="false">http://myrkur.de/thoughts/?p=110#comment-298</guid>
		<description>The problem with this approach isn&#039;t what Jan noted, because if you test your view without the startkey you&#039;ll see that all the random numbers are the same for each run. The issue is that they aren&#039;t evenly distributed. Let&#039;s say you have 4 documents to pick from, and they get the random numbers 0.01, 0.02, 0.9, and 0.91. Almost 90% of the time you are going to be pulling the same &quot;random&quot; document from your view.

Jeff M.</description>
		<content:encoded><![CDATA[<p>The problem with this approach isn&#8217;t what Jan noted, because if you test your view without the startkey you&#8217;ll see that all the random numbers are the same for each run. The issue is that they aren&#8217;t evenly distributed. Let&#8217;s say you have 4 documents to pick from, and they get the random numbers 0.01, 0.02, 0.9, and 0.91. Almost 90% of the time you are going to be pulling the same &#8220;random&#8221; document from your view.</p>
<p>Jeff M.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xjs</title>
		<link>http://myrkur.de/thoughts/2009/05/17/random-documents-from-couchdb/comment-page-1/#comment-269</link>
		<dc:creator>Xjs</dc:creator>
		<pubDate>Mon, 18 May 2009 13:21:24 +0000</pubDate>
		<guid isPermaLink="false">http://myrkur.de/thoughts/?p=110#comment-269</guid>
		<description>I&#039;m aware that view indexes are updated incrementally, so old documents will keep their old random number as key. The trick is that I query the view with a (client-side) random start key, so I only needed a range in which the key can vary.
Random numbers weren&#039;t needed at all, I could as well hash the documents in a way to get a fitting key. I only use random numbers to get entropy and distribute keys well. (And - I&#039;ve tested it - it works perfectly.)</description>
		<content:encoded><![CDATA[<p>I&#8217;m aware that view indexes are updated incrementally, so old documents will keep their old random number as key. The trick is that I query the view with a (client-side) random start key, so I only needed a range in which the key can vary.<br />
Random numbers weren&#8217;t needed at all, I could as well hash the documents in a way to get a fitting key. I only use random numbers to get entropy and distribute keys well. (And &#8211; I&#8217;ve tested it &#8211; it works perfectly.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan</title>
		<link>http://myrkur.de/thoughts/2009/05/17/random-documents-from-couchdb/comment-page-1/#comment-268</link>
		<dc:creator>Jan</dc:creator>
		<pubDate>Mon, 18 May 2009 08:36:35 +0000</pubDate>
		<guid isPermaLink="false">http://myrkur.de/thoughts/?p=110#comment-268</guid>
		<description>Hi,

this map function will blow up on you. Map functions must guarantee the same output for the same input. Things like randomness or Date.now() cannot be used. The transitivity is needed for the incremental updates of view indexes.

Cheers
Jan
--</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>this map function will blow up on you. Map functions must guarantee the same output for the same input. Things like randomness or Date.now() cannot be used. The transitivity is needed for the incremental updates of view indexes.</p>
<p>Cheers<br />
Jan<br />
&#8211;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
