https://softwareengineering.stackexchange.com/questions/260969/original-source-of-seed-9301-49297-233280-random-algorithm Stack Exchange Network Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange [ ] Loading... 1. + Tour Start here for a quick overview of the site + Help Center Detailed answers to any questions you might have + Meta Discuss the workings and policies of this site + About Us Learn more about Stack Overflow the company + Business Learn more about our products 2. 3. current community + Software Engineering help chat + Software Engineering Meta your communities Sign up or log in to customize your list. more stack exchange communities company blog 4. 5. Log in 6. Sign up Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up. Sign up to join this community [ano] Anybody can ask a question [ano] Anybody can answer [an] The best answers are voted up and rise to the top Software Engineering 1. Home 2. 1. Public 2. Questions 3. Tags 4. Users 5. Companies 6. Unanswered 3. Teams Stack Overflow for Teams - Start collaborating and sharing organizational knowledge. [teams-illo-free-si] Create a free Team Why Teams? 1. Teams 2. Create free Team Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. Learn more Original source of `(seed * 9301 + 49297) % 233280` random algorithm? Ask Question Asked 7 years, 9 months ago Modified 7 years, 8 months ago Viewed 19k times 25 5 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? history random Share Follow edited Oct 26, 2014 at 19:40 jlarson asked Oct 26, 2014 at 19:14 user avatar jlarsonjlarson 41111 gold badge33 silver badges88 bronze badges 6 * 11 it's a linear congruent generator but with a fairly small period (only 233k while a 32 bit int allows have a 4 billion period - ratchet freak Oct 26, 2014 at 19:22 * 1 People often copy code directly from books, so it's probably from an old book somewhere and has been copied several times. It also appears to be a limiting case. Possibly helpful: heydari.persiangig.com/Ebooks/Applied_Crypto-Ch11-ch20.pdf/... ict.griffith.edu.au/anthony/info/C/RandomNumbers - user11586 Oct 27, 2014 at 20:29 * 2 Whatever the origin, those are terrible values to use for calculating a seed. - user22815 Oct 27, 2014 at 21:22 * 5 @jlarson a comment is not nearly long enough, but there are two issues at hand. First, as ratchet freak alluded to, the modulo is the maximum period: number of unique numbers before the generator repeats itself. The actual period may be smaller. Second, the other two numbers (mostly the multiplicand) should be relatively prime to the modulo number to ensure a longer period. Ideally the modulo number is the largest prime less than the maximum positive integer that fits in the data type, and the other two numbers are also large primes. - user22815 Nov 4, 2014 at 3:15 * 1 That is the short, short version of why those numbers are terrible, given this is a side discussion and adding an actual answer is not appropriate for this question. I recommend bouncing around Wikipedia and maybe Mathematics or Computer Science for more info, although technically pseudorandom number algorithms are also on-topic at Programmers. - user22815 Nov 4, 2014 at 3:21 | Show 1 more comment 1 Answer 1 Sorted by: Reset to default [Highest score (default) ] 15 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. Share Improve this answer Follow edited Nov 21, 2014 at 9:04 user avatar gnat 21.8k2929 gold badges111111 silver badges273273 bronze badges answered Oct 27, 2014 at 21:17 user avatar HugoHugo 3,49922 gold badges2323 silver badges4040 bronze badges 7 * 5 Wow, if the answer isn't in here I don't know where it would be. Thanks.. // I was kind of hoping to be able to point to some specific research as to why these numbers are special, but this suffices. 9301 is a product of two primes (71x131), 49297 is a prime -- instinctually I feel like that must be relevant. 233280 is not prime -- it equals 2x2x2x2x2x2x3x3x3x3x3x3x5 (or 2^6 * 3^5 * 5) - jlarson Oct 28, 2014 at 18:47 * Sometimes these types of numbers, along with seeds, have a personal significance to the author. A birthday, a favorite number, a random but meaningful statistic, or some combination along the same lines. For example, I use 42 as a seed as an homage to Hitchhikers Guide to the Galaxy. - Brandon Bertelsen 7 hours ago * Didn't Knuth's Seminumerical Algorithms 1st edition show up in 1969? That seems to predate everything else. I don't have 1st edition to check, but I also cannot find any evidence that this LCG was referenced in at least the 3rd edition I have. I think TAOCP (Seminumerical Algorithms) may be a false positive. - Anders 6 hours ago * Yeah the off-beat title "Seminumerical Algorithms" is solely Knuth's, but these numbers don't appear in it: not the current (1997) 3rd edition, not the 1981 2nd edition, and while I don't have access to it right now, I doubt it appeared in the 1969 1st edition either. I've found Google Books often just shows "related" books in which the searched terms don't appear at all. - ShreevatsaR 5 hours ago * "computer methods for mathematical computations" can be 'borrowed' for free at archive.org/details/computermethodsf00fors /page/240/mode/2up but I did not find the values in that book - Willem Hengeveld 1 hour ago | Show 2 more comments Your Answer [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] Thanks for contributing an answer to Software Engineering Stack Exchange! * Please be sure to answer the question. Provide details and share your research! But avoid ... * Asking for help, clarification, or responding to other answers. * Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers. Draft saved Draft discarded [ ] Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Submit Post as a guest Name [ ] Email Required, but never shown [ ] Post as a guest Name [ ] Email Required, but never shown [ ] Post Your Answer Discard By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy Not the answer you're looking for? Browse other questions tagged history random or ask your own question. The Overflow Blog * Great engineering cultures are built on social learning communities * Satellite internet: More useful than sending a car into space (Ep. 470) Featured on Meta * Announcing the Stacks Editor Beta release! Related 2 How does minecraft use a seed to generate a completely unique world? 45 Unit-testing of inherently random/non-deterministic algorithms 2 Generating a Nakagami Random Variable 1 What should I use as a random seed in a Brainfuck? 6 Why do we need a seed in Random Number Generators? 2 Unit testing Markov chain code 0 Is it possible to transfer data with a really unique seed of a psudo random number generator 2 Algorithm for random weighted boolean shuffles? Hot Network Questions * Does check in online change the cancelation policy? * How can I use `enumerate` inside a caption of a figure? * (Mis-)pronunciation of 'accoutrement' that ends in -L not in -NT? * Cryptic Multiplications * The parity of the maximal number of consecutive 1s in the binary expansion of an integer * Limit of Summation K is Not a Number * What do opera and musical singers do in order to feel the pulse of the music? * Forcibly running into an enemy during movement * Sudoku Solver in C without recursion * Antiballast for flying ship * How can I list which TCP Congestion Control Algorighm my Android device is using? * Split two concatenated files * What's the point of grilles on the external doors of our building? * Educators: Let's share the resources we've built! * QGIS How can I transfer atributes from one layer to another when those layers do not share the same number of features? * Do USB *cables* have versions, just like USB *ports* and USB *devices*? * Is this a continuity error in The Dark Knight Rises? * Was Mary Stuart's execution not accompanied by a bill of attainder? * How to transfer information about original mesh * How to programmatically construct a function or a compiled function? * Department is being safety audited so they are making me sign a pile of documents I've never seen before in my several years there * Chinese citizen resident in Schengen area visiting Republic of Ireland * Interpreting lm-sensors output * NULL values appear when taking the sum of two columns taken from Lookup tables more hot questions Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. [https://softwareengi] * Software Engineering * Tour * Help * Chat * Contact * Feedback Company * Stack Overflow * Teams * Advertising * Collectives * Talent * About * Press * Legal * Privacy Policy * Terms of Service * Cookie Settings * Cookie Policy Stack Exchange Network * Technology * Culture & recreation * Life & arts * Science * Professional * Business * API * Data * Blog * Facebook * Twitter * LinkedIn * Instagram Site design / logo (c) 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2022.8.2.42721 Your privacy By clicking "Accept all cookies", you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Accept all cookies Customize settings