<div class="gmail_quote">On Fri, Dec 4, 2009 at 7:38 AM, Duncan Coutts <span dir="ltr">&lt;<a href="mailto:duncan.coutts@googlemail.com">duncan.coutts@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Wait! This is not going to work!</div>
<br>
You cannot use the MTGen from the mersenne-random in a concurrent IO<br>
program because the C code uses a single global mutable RNG state.</blockquote><div><br></div><div>So use the PRNG in the statistics package instead. It&#39;s got some nice features that make it a better choice than mersenne-random for essentially all uses:</div>
<div><ul><li>Faster than mersenne-random</li><li>State is encapsulated, so you can have independent PRNGs in different threads or different library modules</li><li>You can easily seed independent generators from your system&#39;s high-quality PRNG</li>
</ul>It can also generate normally distributed numbers as well as uniformly distributed numbers (which is all that mersenne-random gives you), and it uses a high-quality fast algorithm for the normal distribution, rather than the usual ziggurat which is somewhat broken.</div>
</div>