Skip to main content

Random number generation methods

Short answer

Random numbers are generated by methods such as mid-square, mid-product, constant multiplier, linear congruential X(n+1)=(aX(n)+c) mod m, multiplicative, additive, and hardware sources. Each produces pseudo-random sequences that must be uniform, independent, fast, and have a long period.

What are the different random number generation methods? Explain with examples.

Random numbers for simulation are produced by a deterministic formula (pseudo-random numbers) that gives a sequence that looks random. Main methods:

1. Mid-square method (von Neumann)

Square the seed and take the middle digits as the next number.

Seed 1234 (4 digits): 1234^2 = 01522756, middle four digits give 5227, so R1 = 0.5227. 5227^2 = 27321529 gives 3215 (R2 = 0.3215), then 3362, 3030, 1809 ...

Weakness: the sequence may degenerate quickly. Seed 2100: 2100^2 = 04410000 gives 4100, then 8100, 6100, 2100 and repeats after 4 numbers.

2. Mid-product method

Multiply two successive numbers and take the middle digits. With x0 = 5731 and x1 = 7182: 5731 x 7182 = 41160042, middle 1600; then 7182 x 1600 = 11491200, middle 4912; then 1600 x 4912 = 07859200, middle 8592.

3. Constant multiplier method

Same as mid-product, but every number is multiplied by a fixed constant a. With a = 7182 and x0 = 5731: 7182 x 5731 = 41160042 gives 1600; 7182 x 1600 = 11491200 gives 4912; 7182 x 4912 = 35277984 gives 2779.

4. Linear congruential method (LCG)

X(n+1) = (a X(n) + c) mod m, R(n) = X(n) / m.

Example: a = 17, c = 43, m = 100, X0 = 27. X1 = (17 x 27 + 43) mod 100 = 502 mod 100 = 2; X2 = (34 + 43) mod 100 = 77; X3 = 52; X4 = 27, then it repeats (period 4 only, because the parameters were poorly chosen).

Better example: a = 5, c = 3, m = 16, X0 = 7 gives 6, 1, 8, 11, 10, 5, 12, 15, 14, 9, 0, 3, 2, 13, 4, 7: full period 16. R = 0.375, 0.0625, 0.5 ...

The multiplicative form (c = 0) is X(n+1) = a X(n) mod m. Example: a = 13, m = 64, X0 = 1 gives 13, 41, 21, 17, 29, 57, 37, 33.

5. Additive congruential method

X(n) = (X(n-1) + X(n-k)) mod m. With X(n) = (X(n-1) + X(n-2)) mod 100 and seeds 65, 89 the sequence is 54, 43, 97, 40, 37, 77.

6. Other sources

  • Library functions such as rand() (usually an LCG).
  • Tables of random numbers (RAND table), now rarely used.
  • Hardware (physical) generators using noise or radioactive decay, which are truly random but cannot be repeated.

A good generator has a long period, uniform output and no correlation, and is checked with the chi-square, K-S, runs, gap and poker tests.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Simulation and Modeling chapter 6 questions →