Operations
Research
Question :- In a number of applications dealing with
statistical situations, the use of random numbers, which are almost
numbers. However, since they
are generated by a well defined procedure, they are referred to as Pseudo
random numbers.
Find out various sources
available to you, some of the methods by which random numbers can be
generated. Of these, choose
any three for detailed exploration.
For each of these three methods for generating random/pseudo random
numbers defined the necessary steps, draw the appropriate flowcharts or
write the pseudo code. Now
combine all these to have a programmed in FORTRAN where depending upon the
user's choice, a sequence of random number can be generated based on the
inputs provided by the user.
The project must contain the
following :
- 3-4 pages report containing flowchart/pseudo code
for the selected method for random number generation.
Print
out of FORTRAN program (your program should be well
documented).
GENERATION OF RANDOM NUMBERS
Producing a number by some
algorithm takes away some of the randomness that it should posses. A truly "RANDOM" number or
occurrence can be produced only by some physical phenomenon, such as whiye
noise. For this reason,
numbers produced by algorithms are correctly referred to as PSEUDO RANDOM
NUMBER. But in general
practice we will call it as random numbers.
We are having several methods
of generating the pseudo random numbers. Below I have given three different
method for random numbers out of that we will discuss three of the most
popular method in details for pseudo random number generation.
FIBONACCI METHOD
:-
This kind of random number
generated on the base of fibonacci sequence and is represented by
Xn+1 =
(Xn + Xn-1) modulo M
The method usually produces a
period of length greater than M; however, the pseudorandom number obtained
by using fibonacci method fails to pass the test of randomness,
consequently the method does not give the satisfactory results.
STEP :-1 Let the integer variables X, Y, SUM,
N.
STEP :-2 assign the initial
value to X and Y.
X=0, Y=1
STEP :-3 Input, N, the number
of series to be generated.
STEP :-4 Print the value of X
and Y.
STEP :-5 Initialize the
counter 1=3.
STEP :-6 Calculate the next
number by adding X and Y. SUM = X + Y
STEP :-7 Print the value of
SUM
STEP :-8 Transfer the value
of Y to X.
STEP :-9 Transfer the value
of SUM to Y.
STEP :-10 Compare whether the
series has been generated or not.
STEP :-11 If no, then,
terminate the program, or else go to STEP :-6.
SOURCECODE FOR THE PROGRAMME
OF FIBONNACI METHOD
INTEGER N, X, Y, SUM
X = 0
Y = 1
PRINT *, `ENTER HOW MANY NUMBER :-'
READ (*,*)N
PRINT *, X, Y
DO 30 I=3, N
SUM = X + Y
PRINT *, SUM
X=Y
Y=SUM
30 CONTINUE
END
THE OUTPUT OF THE PROGRAM IS :-
ENTER HOW MANY NUMBER:-
8
0
1
1
2
3
5
8
13


In the squaring method we
will take a number of digits say 4 digit numbers then we will square it,
and pick the central four digits of the product as a random number. The four digit random number is
now square. This process we
will do repeatedly up to the required random number generated.
For example, if we take a
first four digit random number 4321 to generate five random
numbers.
Than,
43212 =
18671041
67102 =
45024100
02412 =
00058081
05802 =
00336400
33642 =
11316496
From the above figures you
will find that taking 4321 as a base number we have generated random
number 3710, 0241, 0580 and 3164.
Pseudocode for the squaring
method is given below to give the idea of the process.
Take a number of digits, say
five, square it, and pick out the central five digits of the product as a
random number. The five digit
random number is now squared, etc. for example :
543212 =
29
50771 041
507712 =
25
77694 441
776942 =
60
36357 636
363572=
13
21831 449
318312 =
47
65925 61
659252 =
43
46105
625
Thus, the random
number 50771, 77694, 36357, 21831, 65925, 46105, ... are generated
starting with 54321.
STEP :-1 Let the integer
variables NO, N, SQRN, X, TEMP.
STEP :-2 Input NO, the first
random number,
STEP :-3 Input N, the number
of series to be generated.
STEP :-4 Initialize the
counter 1=1.
STEP :-5 The number will be
squared, and stored in SQRN.
SQRN = NO*NO
STEP :-6 the value of SQRN
will be divided by 100 and stored another variable TEMP.
TEMP = SQRN / 100.
STEP :-7 Now, to find out the
central value, we, calculate the mod of TEMP and stored in
X.
X = MOD(TEMP, 1000)
STEP :-8 Print the value of
SQRN and X.
STEP :-9 Transfer the value
of Y to FNO.
STEP :-10 Compare whether the
series has been generated or not.
STEP :-11 If no, then
terminate the program or else go to STEP :-5.
SOURCE CODE TO GENERATE
THE RANDOM NUMBER BY METHOD OF SQUARING OR INNER PRODUCT METHOD.
ENTER THE FIRST RANDOM NUMBER
:-
4321
ENTER HOW MANY NUMBER:-
5
NUMBER = 18671041
RANDOM NO = 6710
NUMBER = 45024100
RANDOM NO =
241
NUMBER =
58081
RANDOM NO =
580
NUMBER =
336400
RANDOM NO = 3364
NUMBER = 11316496
RANDOM NO = 3164

3. POWER RESIDUE METHOD
:-
The power residue method of
generating random numbers use a starting value which is neither even nor
ends in A5, and A special constant multiplier. To obtain five digit random
numbers, from the product of the starting value with the constant
multiplier, and pick out the low order five digits as random number, the five digit random number is
now multiplied with the constant multiplier and random number can be
generated up to the required numbers.
For example, if we are taking
five digit number 54921 as a starting number and 97 as a constant
multiplier. We will get the
following product and random number.
54321 * 97
=
5269137
69137 * 97
=
6706289
06289 * 97
=
0610033
10033 * 97
=
0973201
73201 * 97
=
7100497
54321 * 97
=
52
69137
69137 * 97
=
67
06289
06289 * 97
=
06
10033
10033 * 97
=
09
73201
73201 * 97
=
71
00497
00497 * 97
=
00
48209