# The Essential Guide to Random Number Generation Methods

Have you ever felt the need for random numbers in your daily life?

If yes, you may use those generator methods for selecting randomly from the group of people. Also, they can be used in determining the winner in lucky draw schemes. For scientific purposes, random numbers use by advanced simulation processes and cryptography algorithms.

Let’s discuss the random generation methods in this blog, especially there are two methods:

1. Linear Congruential Method
2. Combined Linear Congruential Method

What are Random Numbers?

A number chosen from some specified distribution randomly such that the selection of a large set of these numbers reproduces the underlying distribution is called a random number.

Properties of Random Number

• Uniformity: The random numbers generated should be uniform.
• Independent: Each random number Rt is an independent sample drawn from a continuous uniform distribution between 0 and 1.
• Maximum cycle: It states that the repetition of numbers should be allowed only after a large interval of time.
• Maximum density: The large samples of random numbers should be registered in a given range.

In computer simulation, where a very large number of random numbers is generally required, the random numbers can be obtained by:

• Random numbers may be drawn from the random number tables stored in the memory of the computer.
• Using electronic devices that may be very expensive.
• Using arithmetic operation.

## Random Number Generation Methods

### Linear Congruential Method

A linear congruential method is an algorithm that uses a discontinuous piecewise linear equation to generate a sequence of pseudo-randomized numbers.

⇒ A sequence of integers X1, X2, X3, ….. are produced between zero and m-1 by using the recursive relation as follows:

`X(i+1) = [aX(i)+c] mod m for i=0,1,2,3,.....`

⇒ The initial random integer` X(0)` is known as a seed, and:

```a = multiplier
c = increment
m = modulus```

Let’s feed the above expression with different values of a & c :

a) If `a = 1`, the expression reduces to the additive congruential method.

`X(i+1) = [X(i)+c] mod m`

b) if `c = 0`, the expression reduces to the multiplicative congruential method.

`X(i+1) = [X(i)] mod m`

c) If` a > 1 and c > 0`, then it represents a mixed type congruential method.

`X(i+1) = [aX(i)+c] mod m for i=0,1,2,3,....`

### Combined Linear Congruential Method

A combined linear congruential method is a pseudo-random number generator algorithm that is a combination of two or more multiplicative congruential generators so as to provide good statistical properties and a longer period.

⇒ Let X(i, 1), X(i, 2), X(i, 3),…. are the ith output from k different multiplicative congruential generators, then the combined generator is of the form:

`X(i) = Summation from j = 1 to k[(-1)^(j-1) * X(i, j)] mod m(j) - 1`

This generates random integers between `0 and m(j) - 2`

⇒ The random numbers can be calculated as:

```R(i) = X(i) / m(j), if X(i) > 0

R(i) = [m(j) - 1] / m(j), if X(i> = 0```