Laynetworks  
Web laynetworks.com Google
Home | Site Map | Tell a friends
Management Tutorials
Download
Tutorials
History
Computer Science
Networking
OS - Linux and Unix
Source Code
Script & Languages
Protocols
Glossary
IGNOU
Quiz
About Us
Contact Us
Feedback
 
Sign up for our Email Newsletter
 
Get Paid for Your Tech Turorials / Tips

 

 

Home > Computer Science > Operation Research
CS 01 CS 02 CS 03 CS 04 CS 05 CS 06 CS 07 CS 08 CS 09 CS 10 CS 11 CS 12 CS 13 CS 14 CS 15 CS 16 CS 17
Page : 1 2 3 4 5
Operation Research
 

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.

TOP

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

2. SQUARING OR INNER PRODUCT METHOD :-

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 

TOP

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.

INTEGER NO, MO, SQRN, TEMP, X, N
PRINT *,'ENTER THE FIRST RANDOM NUMBER:-'
READ(*,*) NO
PRINT *, 'ENTER HOW MANY NUMBER:-'
READ (*,*) N
DO 20 I = 1, N
SQRN = NO * NO
MO = MOD (SQRN, 100)
TEMP = SQRN / 100
X = MOD (TEMP, 10000)
PRINT *, 'NUMBER =' , SQRN, 'RANDOM NO
=' , X
20 CONTINUE
END

THE OUTPUT OF THE PROGRAM IS :-

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

TOP

And so on. From the above numbers you will notice that if we take last five-digit as a random number from the product, then we will have 69137, 06289, 10033, 73021 and 497 as a generated random numbers.

The power residue method of generating random numbers uses 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 the random number multiplier, etc. for example :

54321 * 97 = 52 69137
69137 * 97 = 67 06289
06289 * 97 = 06 10033
10033 * 97 = 09 73201
73201 * 97 = 71 00497
00497 * 97 = 00 48209

Thus, the random number 69137, 06289, 10033, 73201, 00497 and 48209 are generated starting 54321.

STEP :- 1 Let the integer variables FNO, NO, X, Y, RNO 

STEP :- 2 Input FNO, the five digit number. 

STEP :- 3 Input NO, the constant number for multiplication. 

STEP :- 4 Input RNO, the number of series to be generated. 

STEP :- 5 Initialize the counter 1=1. 

STEP :- 6 The number will be multiplied by NO, and stored in X. X = FNO * NO

STEP :- 7 Calculate the mod and stored in Y. Y = MOD(X, 10000)

STEP :- 8 Print the value of X and Y. 

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 :-6.

SOURCE CODE TO GENERATE THE RANDOM NUMBER BY METHOD OF POWER OF RESIDUE

INTEGER FNO, NO, X, Y, RNO
PRINT *, 'ENTER ANY FIVE-DIGIT NO :-'
READ (*,*) FNO
PRINT *, 'ENTER CONSTANT TO :-'
READ (*,*) NO
PRINT *, 'ENTER HOW MANY NUMBER :-"
READ (*,*) RNO
D0 30 I = 1, RNO
X ¹ NO * NO
Y = MOD (X, 100000)
PRINT *, 'PRODUCT =' , X, 'RANDOM NO =' , Y
30 CONTINUE
END

THE OUTPUT OF THE PROGRAM IS :-

ENTER ANY FIVE DIGIT NUMBER

54321

ENTER CONSTANT NO :-

20

HOW MANY NUMBER :-

5

PRODUCT = 1086420  RANDOM NO = 86420
PRODUCT = 1728400  RANDOM NO = 28400
PRODUCT = 568000  RANDOM NO = 68000
PRODUCT = 1360000  RANDOM NO = 60000
PRODUCT = 1200000  RANDOM NO = 0

 
TOP
Page : 1 2 3 4 5
CS 01 CS 02 CS 03 CS 04 CS 05 CS 06 CS 07 CS 08 CS 09 CS 10 CS 11 CS 12 CS 13 CS 14 CS 15 CS 16 CS 17
 
Donation | Useful links | Link to Laynetworks.com | Legal | SharePoint Development
Copyright © 2000-2010 Lay Networks All rights reserved.