# Random Number

Every random experiment results in two or more outcomes.
A variable whose values depend upon the outcomes of a random experiment is called a random variable denoted by capital letters X, Y, or Z and their values by the corresponding small letters x, y or z.

Random Numbers and their Generation

Random numbers are a sequence of digits from the set {0,1,2,⋯,9} so that, at each position in the sequence, each digit has the same probability 0.1 of being selected irrespective of the actual sequence, so far constructed.

The simplest ways of achieving such numbers are games of chance such as dice, coins, cards or by repeatedly drawing numbered slips out of a jar. These are usually grouped purely for convenience of reading but this would becomes very tedious for long runs of each digit. Fortunately tables of random digits are widely available now.

Pseudo Random Process

Pseudo Random Process is a process that appears to be random but actually it is not. Pseudo random sequences typically exhibit statistical randomness while being generated by an entirely deterministic causal process. Such a process is easier to produce than a genuinely random one, and has the benefit that it can be used again and again to produce exactly the same numbers and they are useful for testing and fixing software.

For implementation on computers to provide sequence of such digits easily, and quickly, the most common methods are called Pseudo Random Technique.

Here, digit will re-appear in the same order (cycle) eventually. For a good technique the cycle might be tens of thousands of digit long.
Of course the pseudo random digits are not truly random. In fact, they are completely deterministic but they do exhibit most of the properties of random digits. Generally, they methods involves the recursive formula e.g.

$X_{n+1}= a x_n +b\, mod\, m; n=0, 1, 2, …$

a, b and n are suitably chosen integer constants and the seed $x_0$ (a starting number i.e. n = 0) is an integer. (Note mode m means that if the result from formula is greater than m, then divide it by m and keep the remainder as a random number.

Use of this formula gives rise to a sequence of integers each of which is in the random 0 to m – 1.

Example

let a = 13, b=5, and m = 1000, Generate 500 random numbers.

Solution

$x_{n+1}=a x_n \,b\, mod\, 1000; n=0,1,2,…$

let seed $x_0=5$, then for n=0 we have

\begin{align*}
x_{0+1}&=13 \times 5 +5\, mod\, 1000=70\\
x_{1+1}&=13 \times 70 + 5\, mod\, 1000=915
\end{align*}

Application of Random Variables

The random numbers have wide applicability in the simulation techniques (also called Monte Carlo Methods) which have been applied to many problems in the various sciences and one useful in the situation where direct experimentation is not possible, the cost of conducting an experimetn is very high or the experiment takes too much time.

R code to Generate Random Number

# store the pseudo random output
rand.num<-numeric(500)
rand.seed<-5
for(i in 1:500){
rand.seed<-13*rand.seed+5
rand.num[i]<-rand.seed%%1000
}
rand.num

# Pseudo Random Process

A pseudo random process is a process that appears to be random but actually it is not. Pseudo random sequences typically exhibit statistical randomness while being generated by an entirely deterministic causal process. Such a process is easier to produce than a genuinely random one, and has the benefit that it can be used again and again to produce exactly the same numbers and they are useful for testing and fixing software.

The generation of random numbers has many uses (mostly in Statistics, for Random Sampling, and Simulation, Computer Modeling, Markov Chains, Experimental Design). Before modern computing, researchers requiring random numbers would either generate them through various means like coin, dice, cards, roulette wheels, card shuffling etc or use existing random number tables.

A pseudo random variable is a variable which is created by a deterministic procedure (often a computer program or subroutine is used) which (generally) takes random bits as input. The pseudo random string will typically be longer than the original random string, but less random (less entropic, in the information theory sense). This can be useful for randomized algorithms.

Pseudo random numbers are computer generated random numbers and they are not truly random because there is an inherent pattern in any sequence of pseudo numbers.

# Linear Congruential Generator (LCG)

The building block of a simulation study is the ability to generate random numbers where a random number represents the value of a random variable uniformly distributed on (0,1).

The generator is defined by the recurrence relation:

Xi+1=(aXi + C) Modulo m

$a$ and $m$ are given positive integers, $X_n$ is either $0,1, \dots, m-1$ and quantity $\frac{X_n}{m}$ is pseudo random number.

Some conditions are:

1. m>0m is usually large
2. 0<a<m;  (a is the multiplier)
3. 0≤<c<m (c is the increment)
4. 0≤X0<m  (X0is seed or starting value)
5. c and m are relatively prime numbers (there is no common factor between c and m).
6. a−1 is a multiple of every prime factor m
7. a−1 is multiple of 4 if m is multiple of 4

If  c=0, the generator is often called a multiplicative congruential method, or Lehmer RNG. If $c\neq0$ the generator is called a mixed congruential generator.

# Statistical Simulation

Simulation is used before an existing system is altered or a new system built, to reduce the chances of failure to meet specifications, to eliminate unforeseen bottlenecks, to prevent under or over-utilization of resources and to optimize system performance. Models are simulated versions/results.
Simulation depends on unknown (or external/ impositions/ factors) parameters and statistical tools depends on estimates.

• Simulation follows finite sample properties (have to specify n)
• Reasoning of statistical simulation can’t be proofed mathematically)
• Simulation is used to illustrate the things.
• Simulation is used to check the validity of methods.
• Simulation is a technique of representing the real world via computer program.
• Simulation is act of initiating the behavior of some situation or some process by means of something suitably analogous. (especially for the purpose of study or some personal training)
• A simulation is representation of something (usually in smaller scale).
• Simulation is the art of giving false/artificial appearance.

Issues of simulations

• What distribution do the random variable have
• How do we generate these random variables for simulation
• How do we analyze the output of simulations
• How many simulation runs do we need
• How do we improve the efficiency of simulation?