faqts : Science : Mathematics : Random number

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

0 of 1 people (0%) answered Yes
Recently 0 of 1 people (0%) answered Yes

Entry

Math: Number: Random: Generator: Create: How to: How to create a random number generator?

Oct 3rd, 2004 09:15
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 03 October 2004 - 06:05 pm --------------------

Math: Number: Random: Generator: Create: How to: How to create a 
random number generator?

---

The earliest random number generators built upon an idea of John von
Neumann, to square a starting number and to take e.g. the middle 10
digits of that result.

This became then the next starting number, and this procedure was
repeated.

The problem is that after a while you get the same number in as out.

The next step is using the modulo technique:

 (newnumber) = ( (constant1) . (oldnumber) + (constant2) ) modulo 
(constant3)

when you choose the correct constants you might get nice random
sequences.

---

Here follows a C program by Donald Knuth (see book), p. 185:

#define MM 2147483647           /* a Mersenne prime */

#define AA 48271

#define QQ 44488

#define RR 3399

X = AA * (X % QQ) - RR * (long) (X / QQ);

if (X < 0) X+= MM;

---

[book: source: Knuth, Donald - the art of computer programming / 
volume 2 / Edition three, Addison-Wesley, semi-numerical algorithms - 
ISBN 0-201-89684-2 - page 1 to page 193]

---
---

Internet: see also:

---

Math: Number: Random: Link: Overview: Can you give an overview of 
links about random numbers?
http://www.faqts.com/knowledge_base/view.phtml/aid/31689/fid/1712

----------------------------------------------------------------------