SlideShare a Scribd company logo
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

PPTX
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
PPTX
Big o notation
ODT
Probability and random processes project based learning template.pdf
PDF
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
PDF
zero_response
DOC
Programming egs
PPTX
hash
PPTX
Parallel processing -open mp
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Big o notation
Probability and random processes project based learning template.pdf
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
zero_response
Programming egs
hash
Parallel processing -open mp

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

PPT
Lecture06-Random-Number-Genedawrators.ppt
PPTX
Pseudo Random Number
PPTX
Application's of Numerical Math in CSE
PPTX
PPTX
2. Modelling and Simulation in computer 2.pptx
PDF
Silicon valleycodecamp2013
PDF
PDF
Fv2510671071
PPTX
Analysis Framework, Asymptotic Notations
PPT
algorithms-1 master in computer application
PPT
analysis of algorithms and asymptotic complexity
PDF
Algorithm Analysis.pdf
PDF
Introduction to computing Processing and performance.pdf
PPTX
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
PPT
Aad introduction
PPTX
IntroductionToAlgo_v1_1709293290768 (2).pptx
PDF
Fn3410321036
PPT
Collatz Conjecture Research
PPT
Data_Structure_and_Algorithms_Lecture_1.ppt
PPTX
Lecture 7.pptx
Lecture06-Random-Number-Genedawrators.ppt
Pseudo Random Number
Application's of Numerical Math in CSE
2. Modelling and Simulation in computer 2.pptx
Silicon valleycodecamp2013
Fv2510671071
Analysis Framework, Asymptotic Notations
algorithms-1 master in computer application
analysis of algorithms and asymptotic complexity
Algorithm Analysis.pdf
Introduction to computing Processing and performance.pdf
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Aad introduction
IntroductionToAlgo_v1_1709293290768 (2).pptx
Fn3410321036
Collatz Conjecture Research
Data_Structure_and_Algorithms_Lecture_1.ppt
Lecture 7.pptx
Ad

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Insiders guide to clinical Medicine.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Cell Types and Its function , kingdom of life
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
master seminar digital applications in india
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Structure & Organelles in detailed.
Complications of Minimal Access Surgery at WLH
O7-L3 Supply Chain Operations - ICLT Program
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Insiders guide to clinical Medicine.pdf
01-Introduction-to-Information-Management.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Cell Types and Its function , kingdom of life
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Final Presentation General Medicine 03-08-2024.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
master seminar digital applications in india
Microbial diseases, their pathogenesis and prophylaxis
Abdominal Access Techniques with Prof. Dr. R K Mishra
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Structure & Organelles in detailed.
Ad

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.