<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>PCG, A Better Random Number Generator</title><link>http://www.pcg-random.org/</link><description>A Better Random Number Generator</description><atom:link href="http://www.pcg-random.org/rss.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2026 &lt;a href="mailto:oneill@pcg-random.org"&gt;M.E. O'Neill&lt;/a&gt; </copyright><lastBuildDate>Sun, 11 Jan 2026 19:16:05 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>On Being Officially Classed as a Robot</title><link>http://www.pcg-random.org/posts/officially-classed-as-robot.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;Reddit has decided that I am a robot, and robots can't play on Reddit, so my account has been banned.  That has consequences for this site, because I had various links to Reddit posts scattered throughout my blog.  So to fix those links, I had to dust off my &lt;a href="https://getnikola.com/"&gt;Nikola&lt;/a&gt;-based blog machinery and update the links to use &lt;code&gt;archive.org&lt;/code&gt; versions instead.  While I was at it, I figured I might as well write a post about the experience.&lt;/p&gt;
&lt;p&gt;The tl;dr; version is something we all should know: when we pay nothing to participate in a service run by a major tech company that achieves its scale mostly through automation, it's not only the case that we are the product being sold to advertisers, but also that we lack any meaningful power in the relationship.  For as long as things keep working, everything is fine, but at any moment, you can find yourself left wondering what just happened as an online identity winks out of existence without warning or recourse.  Thinking the posts you made on Reddit are something permanent you can link to is a mistake when the company feels and has no obligation to you.  In the rest of this post, I'll say a little more about what I've been up to lately, and how I came to be classified as a bot by Reddit.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/officially-classed-as-robot.html"&gt;Read more…&lt;/a&gt; (10 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>ai</category><category>distributions</category><category>philosophy</category><category>reddit</category><guid>http://www.pcg-random.org/posts/officially-classed-as-robot.html</guid><pubDate>Sat, 10 Jan 2026 03:49:50 GMT</pubDate></item><item><title>Efficiently Generating a Number in a Range</title><link>http://www.pcg-random.org/posts/bounded-rands.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;The vast majority of my posts about random number generation have focused on looking at the properties of different generation schemes.  But, perhaps surprisingly, the performance of your randomized algorithm may hinge not on the generation scheme you chose, but on other factors.  In this post (inspired by and building on an excellent &lt;a href="https://arxiv.org/abs/1805.10941"&gt;recent paper by Daniel Lemire&lt;/a&gt;), we'll explore a common source of overhead in random number generation that frequently outweighs PRNG engine performance.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/bounded-rands.html"&gt;Read more…&lt;/a&gt; (27 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>gjrand</category><category>jsf</category><category>lcg</category><category>mt19937</category><category>pcg</category><category>performance</category><category>sfc</category><category>splitmix</category><category>xoroshiro</category><category>xorshift*</category><category>xoshiro</category><guid>http://www.pcg-random.org/posts/bounded-rands.html</guid><pubDate>Sun, 22 Jul 2018 21:12:28 GMT</pubDate></item><item><title>Some (More) C++ PRNG Implementations</title><link>http://www.pcg-random.org/posts/some-prng-implementations.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;Nearly a year ago, I wrote a post suggesting &lt;a href="http://www.pcg-random.org/posts/other-good-options.html"&gt;some good alternatives to PCG&lt;/a&gt;.  As part of that post, I included links to C++ implementations of those PRNGs, following C++-11 conventions (although omitting rarely-used features such as state I/O).&lt;/p&gt;
&lt;p&gt;Since that post, I've written my own C++ implementations of a few more generation schemes.  Links and brief descriptions below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/some-prng-implementations.html"&gt;Read more…&lt;/a&gt; (3 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>arc4</category><category>gists</category><category>gjrand</category><category>jsf</category><category>lcg</category><category>sfc</category><category>splitmix</category><category>xoroshiro</category><category>xoshiro</category><guid>http://www.pcg-random.org/posts/some-prng-implementations.html</guid><pubDate>Wed, 04 Jul 2018 06:48:01 GMT</pubDate></item><item><title>Exploring Xoshiro's Close-Repeats Flaw</title><link>http://www.pcg-random.org/posts/xoshiro-repeat-flaws.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;In &lt;a href="http://www.pcg-random.org/posts/implausible-output-from-xoshiro256.html"&gt;a recent post&lt;/a&gt;, I noted that the Vigna and Blackman's new &lt;a href="http://xoshiro.di.unimi.it"&gt;Xoshiro&lt;/a&gt; family of PRNGs is prone to some implausible repeats.  I hinted then that I'd write a longer article providing a more in-depth discussion of the issues.  This is that article.&lt;/p&gt;
&lt;p&gt;We'll begin with a slightly deeper exploration of zeroland (which is how I discovered the issue), see how that leads us to find Xoshiro's near-repeats problems, and, finally, determine just how significant the problem is.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/xoshiro-repeat-flaws.html"&gt;Read more…&lt;/a&gt; (31 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>gjrand</category><category>jsf</category><category>testing</category><category>xoroshiro</category><category>xoshiro</category><guid>http://www.pcg-random.org/posts/xoshiro-repeat-flaws.html</guid><pubDate>Mon, 02 Jul 2018 00:41:46 GMT</pubDate></item><item><title>A Birthday Test: Quickly Failing Some Popular PRNGs</title><link>http://www.pcg-random.org/posts/birthday-test.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;My two favorite statistical test suites for PRNGs are PractRand and TestU01, but while they detect statistical flaws of many kinds, detecting those flaws often takes a long time to run, and for various reasons some flaws take a &lt;em&gt;very&lt;/em&gt; long time to detect (if they are detected at all).  In this post, we'll put together a test based around a very classic example from the world of probability theory, &lt;a href="https://en.wikipedia.org/wiki/Birthday_problem"&gt;&lt;em&gt;the Birthday Problem&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In doing so, we'll develop a test that can detect deviations from random behavior in some widely used PRNGs.  We'll eventually be able to detect flaws in &lt;code&gt;std::minstd_rand&lt;/code&gt; and XorShift 32 in 0.01 seconds, and SplitMix, XorShift 64 and Xoroshiro64* in less than half an hour.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/birthday-test.html"&gt;Read more…&lt;/a&gt; (46 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>pcg</category><category>practrand</category><category>splitmix</category><category>testing</category><category>testu01</category><category>xoroshiro</category><guid>http://www.pcg-random.org/posts/birthday-test.html</guid><pubDate>Sat, 09 Jun 2018 22:35:13 GMT</pubDate></item><item><title>Random Invertible Mapping Statistics</title><link>http://www.pcg-random.org/posts/random-invertible-mapping-statistics.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;In my &lt;a href="http://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html"&gt;previous post&lt;/a&gt;, I looked at Bob Jenkins's JSF PRNG which has, at its heart, a random &lt;em&gt;invertible&lt;/em&gt; mapping rather than a random (noninvertible) mapping.  &lt;/p&gt;
&lt;p&gt;I discussed the theory of random (noninvertible) mappings in my post “&lt;a href="http://www.pcg-random.org/posts/too-big-to-fail.html"&gt;&lt;em&gt;Too Big To Fail&lt;/em&gt;&lt;/a&gt;”, which looked at the behavior generators based on this idea.  Although random (noninvertible) mappings produce PRNGs that I consider needlessly flawed (for general-purpose use), their behavior is at least well characterized in the academic literature, particularly by Philippe Flajolet (e.g., &lt;a href="http://algo.inria.fr/flajolet/Publications/book.pdf"&gt;&lt;em&gt;Analytic Combinatorics&lt;/em&gt;&lt;/a&gt;, section VII.3.3 pages 462-467).&lt;/p&gt;
&lt;p&gt;Random &lt;em&gt;invertible&lt;/em&gt; mappings have different properties, being based on a random bijection (which means that the generator can tick backwards as well as forwards if desired), whereas a random (noninvertible) mapping merely requires a random function (which may not be able to go backwards because there is no guarantee that there is only one place we could have come from).  &lt;/p&gt;
&lt;p&gt;If I were to search the literature, I would not be surprised to find that someone else has done a similar analysis of random invertible mappings.  But a quick Google search revealed nothing, and, for me at least, deriving results myself is far more fun than searching for results derived by others, and often a good deal faster if there are no immediate leads. So that's what I've done.  Now, hopefully, if someone Googles it, they'll find &lt;em&gt;something&lt;/em&gt;.  But if you have a good source to cite, please contact me and I'll update this article.&lt;/p&gt;
&lt;p&gt;STOP PRESS: After I posted this article, I found the right term, which turns out not to be &lt;em&gt;random invertible mapping&lt;/em&gt; but &lt;em&gt;random permutation&lt;/em&gt;.  As it turns out, there is a whole &lt;a href="https://en.wikipedia.org/wiki/Random_permutation_statistics"&gt;Wikipedia article on random permutation statistics&lt;/a&gt; which has some of the results I derived here.  I've left my derivations in place because I think they are useful, but you should definitely check out that article as well.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/random-invertible-mapping-statistics.html"&gt;Read more…&lt;/a&gt; (4 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>jsf</category><category>testing</category><category>theory</category><guid>http://www.pcg-random.org/posts/random-invertible-mapping-statistics.html</guid><pubDate>Tue, 29 May 2018 00:29:29 GMT</pubDate></item><item><title>Bob Jenkins's Small PRNG Passes PractRand (And More!)</title><link>http://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;I've been chatting on and off with David Blackman since August, 2017.  Over our various conversations, I've gained huge respect for him and his contributions to random number generation over the last 15 years.  In the course of a recent conversation I asked him about some of his favorite random number generators, and one of the ones he mentioned was &lt;a href="http://burtleburtle.net/bob/rand/smallprng.html"&gt;&lt;em&gt;A Small Noncryptographic PRNG&lt;/em&gt;&lt;/a&gt; by Bob Jenkins.  Even though I had previously been aware of some of Bob Jenkins's other work regarding hash functions, somehow his work on noncryptographic  random number generation fell through the cracks when I was surveying things that were out there back in 2014.  I'll remedy that omission now.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html"&gt;Read more…&lt;/a&gt; (26 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>jsf</category><category>practrand</category><category>testing</category><guid>http://www.pcg-random.org/posts/bob-jenkins-small-prng-passes-practrand.html</guid><pubDate>Sun, 27 May 2018 23:08:33 GMT</pubDate></item><item><title>On Vigna's PCG Critique</title><link>http://www.pcg-random.org/posts/on-vignas-pcg-critique.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;On 14 May 2018, Sebastiano Vigna added &lt;a href="http://pcg.di.unimi.it/pcg.php"&gt;a page to his website&lt;/a&gt; (archived &lt;a href="http://archive.is/VE0sX"&gt;here&lt;/a&gt;) entitled “&lt;em&gt;The wrap-up on PCG generators&lt;/em&gt;” that attempts to persuade readers to avoid various PCG generators.&lt;/p&gt;
&lt;p&gt;That day, he also submitted a link to his critique to &lt;a href="https://web.archive.org/web/20210619165933/https://www.reddit.com/r/programming/comments/8jbkgy/the_wrapup_on_pcg_generators/"&gt;Reddit&lt;/a&gt; (archived &lt;a href="http://archive.is/b76dd"&gt;here&lt;/a&gt;).  I think it is fair to say that his remarks did not get quite the reception he might have hoped for.  Readers mostly seemed to infer a certain animosity in his tone and his criticisms gained little traction with that audience.&lt;/p&gt;
&lt;p&gt;Although I'm pleased to see readers of Reddit thinking critically about these things, it is worth taking the time to dive in and see what what lessons we can learn from all of this.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/on-vignas-pcg-critique.html"&gt;Read more…&lt;/a&gt; (24 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>pcg</category><category>practrand</category><category>splitmix</category><category>testing</category><category>xoroshiro</category><guid>http://www.pcg-random.org/posts/on-vignas-pcg-critique.html</guid><pubDate>Fri, 25 May 2018 23:49:25 GMT</pubDate></item><item><title>Implausible Output from Xoshiro256**</title><link>http://www.pcg-random.org/posts/implausible-output-from-xoshiro256.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;It's now been a week since David Blackman and Sebastiano Vigna
announced new members of the &lt;a href="http://xoroshiro.di.unimi.it"&gt;Xoroshiro family&lt;/a&gt;.  Although I have been busy with a number of other matters, I recognize that interest in these new PRNGs is likely to be high right now, so I have managed to grab a few stolen moments here and there to take a look at their new work.  I plan to write a longer post soon, but my preliminary investigations have turned up enough surprising things that I feel like it's worth sharing some of my discoveries.  As with my previous post on these matters, I'll focus in on their best PRNG, &lt;code&gt;xoshiro256**&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/implausible-output-from-xoshiro256.html"&gt;Read more…&lt;/a&gt; (4 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>practrand</category><category>testing</category><category>xoroshiro</category><category>xoshiro</category><guid>http://www.pcg-random.org/posts/implausible-output-from-xoshiro256.html</guid><pubDate>Thu, 10 May 2018 21:05:00 GMT</pubDate></item><item><title>A Quick Look at Xoshiro256**</title><link>http://www.pcg-random.org/posts/a-quick-look-at-xoshiro256.html</link><dc:creator>M.E. O'Neill</dc:creator><description>&lt;div&gt;&lt;p&gt;On May 4, David Blackman and Sebastiano Vigna announced new members of
the &lt;a href="http://xoroshiro.di.unimi.it"&gt;Xoroshiro family&lt;/a&gt; and a new test
for random number generators (based on the z9 test from
&lt;a href="http://gjrand.sourceforge.net"&gt;gjrand&lt;/a&gt;) that their previous
work fails, all described in a &lt;a href="http://vigna.di.unimi.it/ftp/papers/ScrambledLinear.pdf"&gt;new
paper&lt;/a&gt;.  They claim to have now developed an “all-purpose, rock-solid generator”.  In this post, having had less than a day to review their work, I'll present a few preliminary thoughts on this news, mostly looking at their best new generator, &lt;code&gt;xoshiro256**&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.pcg-random.org/posts/a-quick-look-at-xoshiro256.html"&gt;Read more…&lt;/a&gt; (10 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>practrand</category><category>testing</category><category>xoroshiro</category><category>xoshiro</category><guid>http://www.pcg-random.org/posts/a-quick-look-at-xoshiro256.html</guid><pubDate>Sat, 05 May 2018 16:32:21 GMT</pubDate></item></channel></rss>