SlideShare a Scribd company logo
1 of 2
Download to read offline
Pseudo-Random Number Generators: A New
Approach
Nithin Prince John
Department of Computer Science and Engineering
Sree Buddha College Of Engineering, Pattoor, Kerala - 690529
nithinpj09@gmail.com
Abstract—Random numbers are useful for a variety of purposes, such as generating data encryption keys, simulating and
modeling complex phenomena and for selecting random samples
from larger data sets. Many algorithms have been developed
in an attempt to produce truly random sequences of numbers,
endless strings of digits in which it is theoretically impossible
to predict the next digit in the sequence based on the digits
up to a given point. But the very existence of the algorithm,
no matter how sophisticated, means that the next digit can be
predicted. This has given rise to the term pseudo-random for
such machine-generated strings of digits. They are equivalent to
random-number sequences for most applications, but they are
not truly random according to the rigorous definition. In this
paper, we will discuss an algorithm for pseudorandom generator
belonging to the category of linear congruential generator - the
one most commonly used for generating random integers.

•

ones, twos, etc. that it produces should be roughly equal
over a long period of time.
Lack of predictability: You have no way to predict what
the next number will be unless you know the formula and
the seed (the initial value).
II. L INEAR C ONGRUENTIAL G ENERATOR (LCG)

A linear congruential generator (LCG) is an algorithm that
yields a sequence of randomized numbers calculated with
a linear equation. The method represents one of the oldest
and best-known pseudorandom number generator algorithms.
The heart of an Linear Congruential Generator (LCG) is the
following formula:

Index Terms—LCG, Random seed, Pseudo-random number

I. I NTRODUCTION
Pseudo-Random Number Generators (PRNGs) are efficient,
meaning they can produce many numbers in a short time,
and deterministic, meaning that a given sequence of numbers
can be reproduced at a later date if the starting point in
the sequence is known. Efficiency is a nice characteristic if
your application needs many numbers, and determinism is
handy if you need to replay the same sequence of numbers
again at a later stage. PRNGs are typically also periodic,
which means that the sequence will eventually repeat itself.
While periodicity is hardly ever a desirable characteristic,
modern PRNGs have a period that is so long that it can be
ignored for most practical purposes. A good example of a
PRNG is the linear congruential method. Most PRNGs used in
programming languages use an Linear Congruential Generator
(LCG) so you might as well just use rand() to generate your
random data.
We begin by discussing the characteristics that want to be
considered while designing a formula that generates a pseudorandom number. When designing the formula, the idea is for
it to produce a string of numbers that would look random to
anyone who did not know what the formula is. Characteristics
of a good formula include:
•
•

No repetition: The sequence does not cycle around and
repeat itself.
Good numeric distribution: If the formula is producing
random numbers between 0 and 9, the number of zeros,

Xi+1 = (a ∗ Xi + c)

mod M

where
M is the modulus, M > 0
a is the multiplier, 0 <= a < M
c is the increment, 0 <= c < M
X(0) is the seed value, 0 <= X(0) < M
i is the iterator, i < M
Any pseudo-random number formula depends on the seed
value to start the sequence. This formula assumes the existence
of a variable called random seed, which is initially set to some
number. If you start with the same seed, you will get the same
sequence of values from the formula.
III. I MPLEMENTATION D ETAILS
To create a random and unpredictable sequence, the seed
must be a truly random number. To get this truly random
number for the seed, most programs use the current date and
time, converted to an integer value. Since this is a different
number every time you start the program, it makes a good
seed.
To make our LCG useful we will need a large period. To
do this we have to choose appropriate values for M, a, and
c. To have a maximum period of M the following conditions
must be met:
• M and c are Relatively Prime so the gcd(M, c) = 1.
• (a-1) is divisible by all prime factors of M.
• (a-1) mod 4 = 0 if (M mod 4) = 0.
FUNCTION PSEUDO-RANDOM(M, c, a)
random seed ← compute from system time and date
x ← random seed
b←c
L1: for i ← 0 to M
do x = (ax+c) mod M
print x
if random seed == x
then goto L2
L2: if c > 0
then −−c
if c == 0
then FUNCTION PSEUDO-RANDOM(M, b, a)
if gcd(M,c) == 1
then goto L1
else goto L2
Here the for loop begins to execute for the given values of
M, c, a. When the computed random value matches with the
random seed, it jumps out from the for loop and go to the
part where the value c is decremented till gcd(M,c) == 1, then
the new value of c is passed to the for loop along with the
intial values of M and a while preserving conditions to have
a maximum period.
IV. C ONCLUSION
In the work reported here, an algorithm for producing a
large number of random numbers was designed based on a
linear equation. Here random seed is calculated from current
date and time of the system to create a random and unpredictable sequence. In this algorithm, a gcd function is used
for preserving the conditions to have a maximum period.
R EFERENCES
[1] F. James, A review of pseudorandom number generators, Computer
Physics Communications 60 (1990) 329344, 1990.
[2] Park S. K. and K. W. Miller, Random number generators: good ones are
hard to find,Comm. ACM 31: 1192-1201, 1988.
[3] Niederreiter H, Some linear and nonlinear methods for pseudorandom
number generation,1995.

More Related Content

Similar to Pseudo-Random Number Generators: A New Approach

Application's of Numerical Math in CSE
Application's of Numerical Math in CSEApplication's of Numerical Math in CSE
Application's of Numerical Math in CSEsanjana mun
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013Sanjeev Mishra
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfMemMem25
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfTulasiramKandula1
 
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...Codemotion
 
Aad introduction
Aad introductionAad introduction
Aad introductionMr SMAK
 
Data_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptData_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptISHANAMRITSRIVASTAVA
 
parellel computing
parellel computingparellel computing
parellel computingkatakdound
 
model simulating
model simulatingmodel simulating
model simulatingFEG
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 introchidabdu
 

Similar to Pseudo-Random Number Generators: A New Approach (20)

Pseudo Random Number
Pseudo Random NumberPseudo Random Number
Pseudo Random Number
 
Application's of Numerical Math in CSE
Application's of Numerical Math in CSEApplication's of Numerical Math in CSE
Application's of Numerical Math in CSE
 
Ppt
PptPpt
Ppt
 
Silicon valleycodecamp2013
Silicon valleycodecamp2013Silicon valleycodecamp2013
Silicon valleycodecamp2013
 
Week08.pdf
Week08.pdfWeek08.pdf
Week08.pdf
 
Fv2510671071
Fv2510671071Fv2510671071
Fv2510671071
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdf
 
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
 
Aad introduction
Aad introductionAad introduction
Aad introduction
 
Fn3410321036
Fn3410321036Fn3410321036
Fn3410321036
 
Collatz Conjecture Research
Collatz Conjecture ResearchCollatz Conjecture Research
Collatz Conjecture Research
 
Data_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptData_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.ppt
 
Lecture 7.pptx
Lecture 7.pptxLecture 7.pptx
Lecture 7.pptx
 
Ml ppt at
Ml ppt atMl ppt at
Ml ppt at
 
Gk3611601162
Gk3611601162Gk3611601162
Gk3611601162
 
Hd3512461252
Hd3512461252Hd3512461252
Hd3512461252
 
parellel computing
parellel computingparellel computing
parellel computing
 
model simulating
model simulatingmodel simulating
model simulating
 
Sienna 1 intro
Sienna 1 introSienna 1 intro
Sienna 1 intro
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Pseudo-Random Number Generators: A New Approach

  • 1. Pseudo-Random Number Generators: A New Approach Nithin Prince John Department of Computer Science and Engineering Sree Buddha College Of Engineering, Pattoor, Kerala - 690529 nithinpj09@gmail.com Abstract—Random numbers are useful for a variety of purposes, such as generating data encryption keys, simulating and modeling complex phenomena and for selecting random samples from larger data sets. Many algorithms have been developed in an attempt to produce truly random sequences of numbers, endless strings of digits in which it is theoretically impossible to predict the next digit in the sequence based on the digits up to a given point. But the very existence of the algorithm, no matter how sophisticated, means that the next digit can be predicted. This has given rise to the term pseudo-random for such machine-generated strings of digits. They are equivalent to random-number sequences for most applications, but they are not truly random according to the rigorous definition. In this paper, we will discuss an algorithm for pseudorandom generator belonging to the category of linear congruential generator - the one most commonly used for generating random integers. • ones, twos, etc. that it produces should be roughly equal over a long period of time. Lack of predictability: You have no way to predict what the next number will be unless you know the formula and the seed (the initial value). II. L INEAR C ONGRUENTIAL G ENERATOR (LCG) A linear congruential generator (LCG) is an algorithm that yields a sequence of randomized numbers calculated with a linear equation. The method represents one of the oldest and best-known pseudorandom number generator algorithms. The heart of an Linear Congruential Generator (LCG) is the following formula: Index Terms—LCG, Random seed, Pseudo-random number I. I NTRODUCTION Pseudo-Random Number Generators (PRNGs) are efficient, meaning they can produce many numbers in a short time, and deterministic, meaning that a given sequence of numbers can be reproduced at a later date if the starting point in the sequence is known. Efficiency is a nice characteristic if your application needs many numbers, and determinism is handy if you need to replay the same sequence of numbers again at a later stage. PRNGs are typically also periodic, which means that the sequence will eventually repeat itself. While periodicity is hardly ever a desirable characteristic, modern PRNGs have a period that is so long that it can be ignored for most practical purposes. A good example of a PRNG is the linear congruential method. Most PRNGs used in programming languages use an Linear Congruential Generator (LCG) so you might as well just use rand() to generate your random data. We begin by discussing the characteristics that want to be considered while designing a formula that generates a pseudorandom number. When designing the formula, the idea is for it to produce a string of numbers that would look random to anyone who did not know what the formula is. Characteristics of a good formula include: • • No repetition: The sequence does not cycle around and repeat itself. Good numeric distribution: If the formula is producing random numbers between 0 and 9, the number of zeros, Xi+1 = (a ∗ Xi + c) mod M where M is the modulus, M > 0 a is the multiplier, 0 <= a < M c is the increment, 0 <= c < M X(0) is the seed value, 0 <= X(0) < M i is the iterator, i < M Any pseudo-random number formula depends on the seed value to start the sequence. This formula assumes the existence of a variable called random seed, which is initially set to some number. If you start with the same seed, you will get the same sequence of values from the formula. III. I MPLEMENTATION D ETAILS To create a random and unpredictable sequence, the seed must be a truly random number. To get this truly random number for the seed, most programs use the current date and time, converted to an integer value. Since this is a different number every time you start the program, it makes a good seed. To make our LCG useful we will need a large period. To do this we have to choose appropriate values for M, a, and c. To have a maximum period of M the following conditions must be met: • M and c are Relatively Prime so the gcd(M, c) = 1. • (a-1) is divisible by all prime factors of M. • (a-1) mod 4 = 0 if (M mod 4) = 0.
  • 2. FUNCTION PSEUDO-RANDOM(M, c, a) random seed ← compute from system time and date x ← random seed b←c L1: for i ← 0 to M do x = (ax+c) mod M print x if random seed == x then goto L2 L2: if c > 0 then −−c if c == 0 then FUNCTION PSEUDO-RANDOM(M, b, a) if gcd(M,c) == 1 then goto L1 else goto L2 Here the for loop begins to execute for the given values of M, c, a. When the computed random value matches with the random seed, it jumps out from the for loop and go to the part where the value c is decremented till gcd(M,c) == 1, then the new value of c is passed to the for loop along with the intial values of M and a while preserving conditions to have a maximum period. IV. C ONCLUSION In the work reported here, an algorithm for producing a large number of random numbers was designed based on a linear equation. Here random seed is calculated from current date and time of the system to create a random and unpredictable sequence. In this algorithm, a gcd function is used for preserving the conditions to have a maximum period. R EFERENCES [1] F. James, A review of pseudorandom number generators, Computer Physics Communications 60 (1990) 329344, 1990. [2] Park S. K. and K. W. Miller, Random number generators: good ones are hard to find,Comm. ACM 31: 1192-1201, 1988. [3] Niederreiter H, Some linear and nonlinear methods for pseudorandom number generation,1995.