---
title: "Random number generation methods"
subject: "Simulation and Modeling"
chapter: 6
key: "semester_8/simulation_and_modeling:rn-generation-methods"
source: https://www.bctengineer.com/q/semester_8/simulation_and_modeling/rn-generation-methods
site: BCT Engineering
---

# Random number generation methods

Simulation and Modeling · Chapter 6: Random Number

- Asked in: 2073 Bhadra, 8 marks
- Video: [Random Number Generation Techniques in Simulation & Modeling | LCG, Mixed & Additive Generator](https://www.youtube.com/watch?v=GV3d7pEe5A8) — Educationify
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/simulation_and_modeling/rn-generation-methods
- Whole chapter: https://www.bctengineer.com/md/semester_8/simulation_and_modeling/chapter-6

## Question

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

## 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.

## Answer

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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How does the mid-square method get the next number?
   A. Multiplies the seed by a constant and takes the remainder
   B. Squares the seed and takes the middle digits
   C. Adds the last two numbers and takes mod m
   D. Reads a table of random numbers
   Answer: B. The seed is squared and the middle digits form the next number. (Key point: Mid-square method)

2. Why is the mid-square method considered weak?
   A. It needs very large memory
   B. It cannot produce decimals
   C. It may degenerate quickly into a short repeating cycle
   D. It always gives numbers above 0.5
   Answer: C. For example seed 2100 gives 4100, 8100, 6100, 2100 and repeats after only 4 numbers. (Key point: Weakness of mid-square)

3. Which is the linear congruential formula?
   A. X(n+1) = (a X(n) + c) mod m
   B. X(n+1) = X(n)^2 mod m
   C. X(n+1) = (X(n) + X(n-k)) mod m
   D. X(n+1) = a + c X(n)
   Answer: A. LCG is X(n+1) = (a X(n) + c) mod m, with R = X/m. (Key point: LCG formula)

4. With a = 17, c = 43, m = 100, X0 = 27, what is X1 and what does it show?
   A. X1 = 2; the sequence has a short period of only 4
   B. X1 = 77; it has full period 100
   C. X1 = 502; it is valid as it is
   D. X1 = 2; it has full period
   Answer: A. (17 x 27 + 43) mod 100 = 502 mod 100 = 2, and the sequence returns to 27 after 4 values, so the parameters were poor. (Key point: LCG example)

## Related in Simulation and Modeling

- [Random number; problems in generating pseudo-random](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Arn-problems-pseudo-random) — Simulation and Modeling, chapter 6
- [Short note: Convolution in random number](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Aconvolution-short-note) — Simulation and Modeling, chapter 6
- [Random number properties and Gap test](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Arn-properties-gap-test) — Simulation and Modeling, chapter 6, asked 4×
- [Random number properties; KS test algorithm](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Arn-properties-ks-algorithm) — Simulation and Modeling, chapter 6
- [Properties and generation techniques of RN](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Arn-properties-generation-techniques) — Simulation and Modeling, chapter 6
