<?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: Return random subset of N elements of a given array</title> <atom:link href="http://www.fsmpi.uni-bayreuth.de/~dun3/archives/return-random-subset-of-n-elements-of-a-given-array/98.html/feed" rel="self" type="application/rss+xml" /><link>http://www.fsmpi.uni-bayreuth.de/~dun3/archives/return-random-subset-of-n-elements-of-a-given-array/98.html</link> <description>This is a collection of interesting stuff that I found on the web or stuff I worked on at the time.</description> <lastBuildDate>Tue, 07 Feb 2012 20:01:32 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>By: Andrii</title><link>http://www.fsmpi.uni-bayreuth.de/~dun3/archives/return-random-subset-of-n-elements-of-a-given-array/98.html/comment-page-1#comment-363317</link> <dc:creator>Andrii</dc:creator> <pubDate>Sun, 15 Jan 2012 09:46:29 +0000</pubDate> <guid
isPermaLink="false">http://saftsack.fs.uni-bayreuth.de/~dun3/archives/return-random-subset-of-n-elements-of-a-given-array/98.html#comment-363317</guid> <description>Hi. Thanks a lot for your code. It is very helpful.
There is one mistake in your code:
int swapPosition = i + m_random.Next(size - i);
In this case, swapping will occur only within first symbols of &quot;size&quot; length. So we won&#039;t get fully random subset, but random subset of the first symbols in array.
The correct is:
int swapPosition = i + m_random.Next(m_sourceArray.Count - i);</description> <content:encoded><![CDATA[<p>Hi. Thanks a lot for your code. It is very helpful.<br
/> There is one mistake in your code:<br
/> int swapPosition = i + m_random.Next(size &#8211; i);<br
/> In this case, swapping will occur only within first symbols of &#8220;size&#8221; length. So we won&#8217;t get fully random subset, but random subset of the first symbols in array.<br
/> The correct is:<br
/> int swapPosition = i + m_random.Next(m_sourceArray.Count &#8211; i);</p> ]]></content:encoded> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 2/8 queries in 0.004 seconds using disk

Served from: btfmx2.fs.uni-bayreuth.de @ 2012-02-12 06:44:33 -->
