<?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: Random Number Generators: There should be only one</title>
	<atom:link href="http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/</link>
	<description>Rants and opinion interspersed with awe-inspiring tales of heoric software engineering endeavours.</description>
	<lastBuildDate>Tue, 02 Mar 2010 10:03:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Merauderweb</title>
		<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/comment-page-1/#comment-3536</link>
		<dc:creator>Merauderweb</dc:creator>
		<pubDate>Thu, 05 Feb 2009 06:57:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.uncommons.org/?p=357#comment-3536</guid>
		<description>&lt;strong&gt;Random numbers...&lt;/strong&gt;

Random numbers...</description>
		<content:encoded><![CDATA[<p><strong>Random numbers&#8230;</strong></p>
<p>Random numbers&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mats Henricson</title>
		<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/comment-page-1/#comment-3453</link>
		<dc:creator>Mats Henricson</dc:creator>
		<pubDate>Wed, 14 Jan 2009 11:04:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.uncommons.org/?p=357#comment-3453</guid>
		<description>How can there not be a correlation? The pseaudo random numbers are generated by a deterministic machine, right?

If you have a true RNG, where numbers are truly random, then sure, you can pick and choose any sequence you want, and the newly created sequence will be as random as the original sequence.

I tried to find the reference to my claim in the two books I mentioned, and it isn&#039;t there. I think it is in the Communications of the ACM paper &quot;Random Number Generators: Good ones are Hard to Find&quot; from October 1988. It is available to buy for $10, which I thought was too much to prove my point. For you, perhaps it makes sense to get your company to pay for that paper? If I remember correctly, it was very good.

Good luck!</description>
		<content:encoded><![CDATA[<p>How can there not be a correlation? The pseaudo random numbers are generated by a deterministic machine, right?</p>
<p>If you have a true RNG, where numbers are truly random, then sure, you can pick and choose any sequence you want, and the newly created sequence will be as random as the original sequence.</p>
<p>I tried to find the reference to my claim in the two books I mentioned, and it isn&#8217;t there. I think it is in the Communications of the ACM paper &#8220;Random Number Generators: Good ones are Hard to Find&#8221; from October 1988. It is available to buy for $10, which I thought was too much to prove my point. For you, perhaps it makes sense to get your company to pay for that paper? If I remember correctly, it was very good.</p>
<p>Good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/comment-page-1/#comment-3447</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 13 Jan 2009 13:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.uncommons.org/?p=357#comment-3447</guid>
		<description>@James, good point about the period, but if you choose the right RNG (such as &lt;a href=&quot;http://en.wikipedia.org/wiki/Multiply-with-carry#Complementary-multiply-with-carry_generators&quot; rel=&quot;nofollow&quot;&gt;CMWC&lt;/a&gt;), it&#039;s period will be so long that in practice it doesn&#039;t really matter.  The point about the complications of repeatability was one of things I was addressing.  Yes, you can have one RNG per thread, and that&#039;s not necessarily a bad thing, as long as you seed them correctly and independently.

@Mats, the complexity I meant was the complexity of multi-threading.  Even so, I still believe that you can use a shared RNG for different purposes without problems.  Each individual output is supposed to be independent of the other outputs.  We know that for a PRNG they are not really independent because of the way that the algorithm works, but from a statistical point of view there is no correlation.

I can&#039;t see how there would be any problem for a true RNG, so I assume you are arguing only about PRNGs.  In this case, I would guess that the presence or absence of any problems depends largely on the quality of the algorithm.

I&#039;m a programmer, not a mathematicican, so I decided to test these scenarios.  I just ran &lt;a href=&quot;http://stat.fsu.edu/~geo&quot; rel=&quot;nofollow&quot;&gt;Diehard&lt;/a&gt; on the &lt;a href=&quot;https://uncommons-maths.dev.java.net/nonav/api/org/uncommons/maths/random/MersenneTwisterRNG.html&quot; rel=&quot;nofollow&quot;&gt;MersenneTwisterRNG&lt;/a&gt; and &lt;a href=&quot;https://uncommons-maths.dev.java.net/nonav/api/org/uncommons/maths/random/AESCounterRNG.html&quot; rel=&quot;nofollow&quot;&gt;AESCounterRNG&lt;/a&gt;.  Instead of using a contiguous sub-sequence of the RNG output, I created the input files from every 10th value.

I then ran it again with input files that were created by generating 10 times more numbers than required and randomly selecting 10% of them (using an independent RNG - different algorithm).

In both cases Diehard found no statistical anomalies in the output.  The results were just as good as when the test was run with contiguous values.

On the subject of poker, it absolutely is necessary that online poker sites have well distributed values.  It is required in order to be able to obtain a licence to operate the site.  The RNG is subjected to rigourous testing and analysis.</description>
		<content:encoded><![CDATA[<p>@James, good point about the period, but if you choose the right RNG (such as <a href="http://en.wikipedia.org/wiki/Multiply-with-carry#Complementary-multiply-with-carry_generators" rel="nofollow">CMWC</a>), it&#8217;s period will be so long that in practice it doesn&#8217;t really matter.  The point about the complications of repeatability was one of things I was addressing.  Yes, you can have one RNG per thread, and that&#8217;s not necessarily a bad thing, as long as you seed them correctly and independently.</p>
<p>@Mats, the complexity I meant was the complexity of multi-threading.  Even so, I still believe that you can use a shared RNG for different purposes without problems.  Each individual output is supposed to be independent of the other outputs.  We know that for a PRNG they are not really independent because of the way that the algorithm works, but from a statistical point of view there is no correlation.</p>
<p>I can&#8217;t see how there would be any problem for a true RNG, so I assume you are arguing only about PRNGs.  In this case, I would guess that the presence or absence of any problems depends largely on the quality of the algorithm.</p>
<p>I&#8217;m a programmer, not a mathematicican, so I decided to test these scenarios.  I just ran <a href="http://stat.fsu.edu/~geo" rel="nofollow">Diehard</a> on the <a href="https://uncommons-maths.dev.java.net/nonav/api/org/uncommons/maths/random/MersenneTwisterRNG.html" rel="nofollow">MersenneTwisterRNG</a> and <a href="https://uncommons-maths.dev.java.net/nonav/api/org/uncommons/maths/random/AESCounterRNG.html" rel="nofollow">AESCounterRNG</a>.  Instead of using a contiguous sub-sequence of the RNG output, I created the input files from every 10th value.</p>
<p>I then ran it again with input files that were created by generating 10 times more numbers than required and randomly selecting 10% of them (using an independent RNG &#8211; different algorithm).</p>
<p>In both cases Diehard found no statistical anomalies in the output.  The results were just as good as when the test was run with contiguous values.</p>
<p>On the subject of poker, it absolutely is necessary that online poker sites have well distributed values.  It is required in order to be able to obtain a licence to operate the site.  The RNG is subjected to rigourous testing and analysis.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mats Henricson</title>
		<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/comment-page-1/#comment-3446</link>
		<dc:creator>Mats Henricson</dc:creator>
		<pubDate>Tue, 13 Jan 2009 08:10:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.uncommons.org/?p=357#comment-3446</guid>
		<description>Sorry, I think you are wrong! Picking numbers 1, 11, 21, 31,... or randomly, will give you a LESS well distributed random sequence than picking values 1, 2, 3, 4, ...

Many people try to be smart, by first picking a good RNG, then they believe that the randomness will be even better if they pick numbers randomly out of the generated sequences. The fact is that the numbers get LESS randomly distributed that way, because these sequences aren&#039;t really random, they&#039;re pseudo random.

I did some research on this when I was writing up a proposal for having standard RNG classes in ISO/ANSI C++, around 1995 or so.

You DID actually write that one RNG per application would be a good idea:

   A single instance can be accessed from multiple threads without
   causing problems, so there usually is no need to have multiple
   RNGs even in complex applications.

In complex applications you normally need more than just one random sequence, right?

I see the need to disguise the RNG used, for example in poker applications. Picking randomly out of such sequences, or every tenth number, will of course make it less easy for a bystander to guess the seed or RNG type, but the used numbers will be less well distributed. Perhaps this will not matter much, but if you do scientific calculations (not poker) I would NOT recommend such a technique.

And, yes, I would recommend having one RNG per table. But preventing an educated guess of what seed was used, and what the RNG is used, is of course a problem.

I don&#039;t have my reference literature at hand (I will tomorrow), but I think my claim is fairly well documented in, for example, &quot;Numerical Methods&quot; by Dahlquist and Björk, or possibly &quot;Numerical Recipes 3rd Edition&quot; by Press, Teukolsky, Vetterling and Flannery.</description>
		<content:encoded><![CDATA[<p>Sorry, I think you are wrong! Picking numbers 1, 11, 21, 31,&#8230; or randomly, will give you a LESS well distributed random sequence than picking values 1, 2, 3, 4, &#8230;</p>
<p>Many people try to be smart, by first picking a good RNG, then they believe that the randomness will be even better if they pick numbers randomly out of the generated sequences. The fact is that the numbers get LESS randomly distributed that way, because these sequences aren&#8217;t really random, they&#8217;re pseudo random.</p>
<p>I did some research on this when I was writing up a proposal for having standard RNG classes in ISO/ANSI C++, around 1995 or so.</p>
<p>You DID actually write that one RNG per application would be a good idea:</p>
<p>   A single instance can be accessed from multiple threads without<br />
   causing problems, so there usually is no need to have multiple<br />
   RNGs even in complex applications.</p>
<p>In complex applications you normally need more than just one random sequence, right?</p>
<p>I see the need to disguise the RNG used, for example in poker applications. Picking randomly out of such sequences, or every tenth number, will of course make it less easy for a bystander to guess the seed or RNG type, but the used numbers will be less well distributed. Perhaps this will not matter much, but if you do scientific calculations (not poker) I would NOT recommend such a technique.</p>
<p>And, yes, I would recommend having one RNG per table. But preventing an educated guess of what seed was used, and what the RNG is used, is of course a problem.</p>
<p>I don&#8217;t have my reference literature at hand (I will tomorrow), but I think my claim is fairly well documented in, for example, &#8220;Numerical Methods&#8221; by Dahlquist and Björk, or possibly &#8220;Numerical Recipes 3rd Edition&#8221; by Press, Teukolsky, Vetterling and Flannery.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Hofmann</title>
		<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/comment-page-1/#comment-3445</link>
		<dc:creator>James Hofmann</dc:creator>
		<pubDate>Tue, 13 Jan 2009 06:26:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.uncommons.org/?p=357#comment-3445</guid>
		<description>I&#039;m pretty sure the answer is something like: if you are using a PRNG for the purpose of defeating predictable patterns(as in poker games), you are doling out numbers from a finite sequence that eventually repeats. Distributing the generation sequence means you generate more numbers and decreases the time to repeat. As well, if you want to reproduce results, a shared PRNG complicates matters considerably.

If you were using a truly random source, I don&#039;t think the first would matter, and the latter would be made impossible.</description>
		<content:encoded><![CDATA[<p>I&#8217;m pretty sure the answer is something like: if you are using a PRNG for the purpose of defeating predictable patterns(as in poker games), you are doling out numbers from a finite sequence that eventually repeats. Distributing the generation sequence means you generate more numbers and decreases the time to repeat. As well, if you want to reproduce results, a shared PRNG complicates matters considerably.</p>
<p>If you were using a truly random source, I don&#8217;t think the first would matter, and the latter would be made impossible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/comment-page-1/#comment-3442</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Tue, 13 Jan 2009 02:26:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.uncommons.org/?p=357#comment-3442</guid>
		<description>Mats, can you expand on what you see as the problem?

I wasn&#039;t specifically thinking about one RNG for different purposes, rather the scenario where you have one problem split across multiple threads (for speed-up reasons) with each thread doing an equal amount of work.  If a single RNG feeds the threads in round-robin fashion, then thread 1 will get the 1st, 11th, 21st, 31st... numbers from the sequence.  Taking every 10th number from an RNG and ignoring the intermediate values yields a sequence that is no less random than using all of the values.  In fact this technique is sometimes used to make pseudorandom sequences harder to reverse-engineer.

But you&#039;re specifically talking about &quot;randomly&quot; picking the values from the RNG.  Correct me if I&#039;m wrong, I assume you&#039;re talking about the uncertainty introduced by having several threads fighting over a single RNG (in the case where we are making no effort to maintin repeatability).  Are you saying that having multiple clients for a single RNG introduces bias?

For example, an Internet poker site has thousands of tables.  Each of these tables has to shuffle a deck of cards for each hand.  Are you saying that each table needs its own RNG to make it fair, rather than calling into a shared RNG whenever it needs to shuffle?</description>
		<content:encoded><![CDATA[<p>Mats, can you expand on what you see as the problem?</p>
<p>I wasn&#8217;t specifically thinking about one RNG for different purposes, rather the scenario where you have one problem split across multiple threads (for speed-up reasons) with each thread doing an equal amount of work.  If a single RNG feeds the threads in round-robin fashion, then thread 1 will get the 1st, 11th, 21st, 31st&#8230; numbers from the sequence.  Taking every 10th number from an RNG and ignoring the intermediate values yields a sequence that is no less random than using all of the values.  In fact this technique is sometimes used to make pseudorandom sequences harder to reverse-engineer.</p>
<p>But you&#8217;re specifically talking about &#8220;randomly&#8221; picking the values from the RNG.  Correct me if I&#8217;m wrong, I assume you&#8217;re talking about the uncertainty introduced by having several threads fighting over a single RNG (in the case where we are making no effort to maintin repeatability).  Are you saying that having multiple clients for a single RNG introduces bias?</p>
<p>For example, an Internet poker site has thousands of tables.  Each of these tables has to shuffle a deck of cards for each hand.  Are you saying that each table needs its own RNG to make it fair, rather than calling into a shared RNG whenever it needs to shuffle?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mats Henricson</title>
		<link>http://blog.uncommons.org/2009/01/11/random-number-generators-there-should-be-only-one/comment-page-1/#comment-3438</link>
		<dc:creator>Mats Henricson</dc:creator>
		<pubDate>Mon, 12 Jan 2009 23:13:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.uncommons.org/?p=357#comment-3438</guid>
		<description>Hi!

Unfortunately, your advice is not good. You should have one RNG per random number sequence you want. Having one global RNG used everywhere, for different purposes, will not be good, since picking random random numbers from a good generator will NOT result in well distributed numbers. Please note that I did not write &quot;random&quot; twice after eachother in the last sentence by mistake.

Mats</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>Unfortunately, your advice is not good. You should have one RNG per random number sequence you want. Having one global RNG used everywhere, for different purposes, will not be good, since picking random random numbers from a good generator will NOT result in well distributed numbers. Please note that I did not write &#8220;random&#8221; twice after eachother in the last sentence by mistake.</p>
<p>Mats</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.253 seconds -->
