If you search for examples of creating a seeded (pseudo)Random number generator, you will run into stuff like this (specific example http://indiegamr.com/generate-repeatable-random-numbers-in-js/):

``````// the initial seed
Math.seed = 6;

// in order to work 'Math.seed' must NOT be undefined,
// so in any case, you HAVE to provide a Math.seed
Math.seededRandom = function(max, min) {
max = max || 1;
min = min || 0;

Math.seed = (Math.seed * 9301 + 49297) % 233280;
var rnd = Math.seed / 233280;

return min + rnd * (max - min);
}
``````

Those specific numbers (9301, 49297, 233280) and algorithm are used over and over, but nobody seems to have a definitive reference for this. Who invented this algorithm and tested the distribution? Is there a paper or something to cite?

asked Oct 26, 2014 at 19:14

jlarsonjlarson

6

A quick search of Google Books shows these numbers (9301, 49297, 233280) have been used in a number of references:

• Numerical Recipes in FORTRAN 77
• An Introduction to Numerical Methods in C++
• CGI Developer's Resource: Web Programming in TCL and PERL
• Effective Fortran 77 for Engineers & Scientists
• JavaScript development
• All on C
• Java Examples in a Nutshell
• Seminumerical algorithms
• An Introduction To Mechanics

The oldest is 1977's Computer methods for mathematical computations by George Elmer Forsythe, Michael A. Malcolm, Cleve B. Moler (Prentice-Hall), although Google doesn't show where the text was used in the book so it cannot be verified.

The earliest showing the text is Numerical Recipes in Pascal (First Edition): The Art of Scientific Computing, Volume 1 by Press, Teukolsky, Vetterling and Flannery in a full-page table of "Constants for Portable Random Number Generators". These particular numbers are given with an overflow at 2^31.

The Numerical Recipes series of books are hugely popular, and have been in print since 1986.

gnat