SlideShare a Scribd company logo
Pseudorandom Numbers
-by Alex Roodman
Part 1: What does
“Pseudorandom” mean?
The word “Pseudorandom”
can be split into these two parts:
pseudo, random. The “random” part is
self explanatory, but then there is
“pseudo.”
“Pseudo” implies that it only
mimicks randomness. This is often bad for
random numbers, but some computer
programs require random numbers, such
as programs for reaction tests. You don’t
want someone to be able to predict what
they’re reacting to, and the given output
will still be generated by a computer.
Computers can’t do better that generate
pseudorandom numbers.
This presentation is about
different simple pseudorandom
number generators, and their
qualities. The results will be
presented via. histogram.
One quality of a
pseudorandom number generator is
that it is equally likely to be any
number in a specified range. If you
flip a coin several times, it’s equally
likely to be either heads or tails.
Another quality is how random
the changes in the numbers are. If you
count 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, the
number you count at any given moment
is equally likely to be any number from 1
to 10, but it’s still not random.
Part 2: How the Difference
works
Understanding the
first quality discussed in this
presentation is trivial: The
numbers need to be generated
about as often as each other.
The difference works differently,
though.
Imagine this: You are
rolling a fair die. First, you roll a 1.
The next number rolled is equally
likely to be any number from 1 to 6.
Thus, the difference between 1 and
the next number rolled is equally
likely to be 0, 1, 2, 3, 4, or 5. We
can make a small histogram of this,
repeated. For 2, the number can
change by -1, 0, 1, 2, 3, or 4. For 3,
we have -2, -1, 0, 1, 2, and 3, etc.
The histogram would look
like this:
Now we know
what to expect in the
difference of the
pseudorandom numbers.
-5
-4
-3
-2
-1
0
1
2
3
4
5
Generator #1
𝑔1 𝑥 ≡ e 𝑥
mod 1
If you take 𝑎 𝑥mod 𝑏,
(where both 𝑎 and 𝑏 are integers,)
and count 𝑥, then as long as 𝑎 and 𝑏
share no factors, you can get back
each number from 1 to 𝑏 − 1
exactly once before you get the
same number as before. Thus,
modular exponentiation is uniformly
distributed.
In simpler
words, if you multiply
a number by itself
several times, and
subtract another
number from it as
many times as
possible without going
below 0, you will get a
random number. This
is the method I tested
here.
Based on this, the
pseudorandom numbers
generated here will be well
distributed. The only problem that
could happen is if there is a bad
distribution of the differences of
numbers.
Testing
Generator #1
As you see below, the
distribution of the numbers only has a
few bumps in it. The distribution of the
differences is also in the triangle shape
that we wanted.
The only disappointment
is that the generator can’t generate
many numbers. If you do exactly
what the generator says, you can
only generate 31 numbers. If you
use a simpler way of calculating the
numbers, you can generate up to
713 numbers. This is a good
pseudorandom number generator,
but the calculations are just too
much for the computer.
= Difference
= Numbers Generated
Generator #2
𝑔2 𝑥 = sin2 𝑥
This function is
basically a wave that goes up
and down very quickly. One way
to represent this is taking a
spring, stretching it, and
flattening it sideways. You will
see a wave.
If you look at the
wave, you will see that it
stays at either the far top or
the far bottom for a bit
before it continues. This
could cause a problem with
the distribution.
Testing Generator #2
As expected,
the numbers are
generated more often
on the sides.
What’s curious,
though, is why the difference
in the numbers is always
around 0. This means that
the number generated
slowly travels back and forth,
between 1 and 0.
= Difference
= Numbers Generated
Generator #3
Imagine that you spin
a spinner, and it keeps spinning
forever. It keeps going at the
same speed all the time. It
takes 10 seconds to make a full
rotation, and there are 10
numbers total. Every 7
seconds, you write down what
number the spinner is over.
This is equally likely to be any
number on the spinner. We use
this concept in this generator.
The only thing that
might go wrong is the distribution
of the differences.
𝑔3 𝑥 ≡ 𝑒𝑥 mod 1
Testing Generator #3
The distribution of the
numbers generated is near perfect.
The distribution of the differences,
though, is a different matter. The difference between
the outputs can be exactly one of
two numbers. This is a little
disappointing, because we were
sort of relying on that for this to be
a good generator. The last generator
wasn’t that good, but at least it
could have a difference of more
than two numbers.
= Difference
= Numbers Generated
Generator #4
𝑔4 𝑥 ≡ ln 𝑥 mod 1 This generator is (spoiler alert) the
worst yet. It is intended, though, because using
this, you can see what bad qualities you don’t
want to see in a pseudorandom number
generator. The difference between the numbers
in this generator get smaller and smaller, and it
doesn’t even have a distribution.
Mathematicians, before you call this bogus, go
to
https://www.khanacademy.org/cs/pseudorand
om-number-generators/4733195911168000,
and look for something that says //Change to
try different generators. Look to the left of it,
and change the number in the brackets to 4.
Click restart, and watch.
Testing Generator #4
As expected, this wasn’t a very
good generator. The distribution of the
differences is basically a single spike,
The
distribution here, if you
keep generating
numbers, won’t ever
stay the same. By this,
we can’t tell whether
the distribution here is
even or spiky.
= Difference
= Numbers Generated
Conclusion
It seems that most of these generators
are terrible. The best one of them is too tough on
the computer, even though it works beautifully.
This shows how hard it is to
create these generators. One of the best
generators used is called the Mersenne
Twister. This generator is hard to
understand, and involves the
distribution of Mersenne Primes.
Making these good generators is
extremely difficult.

More Related Content

PPTX
Pseudo Random Number
PDF
Monte carlo simulation
PPTX
Midsquare method- simulation system
PDF
Random number generators
PDF
What is pseudo random number
PPT
Or ppt,new
PPT
Monte Carlo Simulation - Paul wilmott
PPTX
Monte carlo simulation
Pseudo Random Number
Monte carlo simulation
Midsquare method- simulation system
Random number generators
What is pseudo random number
Or ppt,new
Monte Carlo Simulation - Paul wilmott
Monte carlo simulation

What's hot (15)

PPTX
Unit 3 random number generation, random-variate generation
PPT
Monte Carlo Simulation Of Heston Model In Matlab(1)
PPTX
The monte carlo method
PDF
High Dimensional Quasi Monte Carlo Method in Finance
PPT
Monte carlo integration, importance sampling, basic idea of markov chain mont...
PPTX
Understanding Statistics 2#2 The Normal Probability Distribution
PPT
Monte carlo
PPTX
Monte carlo simulation
PPTX
My Math Project
PDF
Lecture: Monte Carlo Methods
PDF
The use of Monte Carlo simulation in quantitative risk assessment of IT projects
PDF
model simulating
 
PDF
Smart Attacks on the integrity of the Internet of Things Avoiding detection b...
PPS
Innovative Combat By Stoutheart
PDF
Applied 40S March 3, 2009
Unit 3 random number generation, random-variate generation
Monte Carlo Simulation Of Heston Model In Matlab(1)
The monte carlo method
High Dimensional Quasi Monte Carlo Method in Finance
Monte carlo integration, importance sampling, basic idea of markov chain mont...
Understanding Statistics 2#2 The Normal Probability Distribution
Monte carlo
Monte carlo simulation
My Math Project
Lecture: Monte Carlo Methods
The use of Monte Carlo simulation in quantitative risk assessment of IT projects
model simulating
 
Smart Attacks on the integrity of the Internet of Things Avoiding detection b...
Innovative Combat By Stoutheart
Applied 40S March 3, 2009
Ad

Viewers also liked (6)

PPT
Simulation in terminated system
PPT
Random variate generation
PDF
Pseudo Random Number Generators
PPTX
Random Number Generation
PPSX
Generate and test random numbers
Simulation in terminated system
Random variate generation
Pseudo Random Number Generators
Random Number Generation
Generate and test random numbers
Ad

Similar to Pseudorandom number generators powerpoint (20)

PPTX
2. Modelling and Simulation in computer 2.pptx
PDF
40120140502003
PDF
Pseudo-Random Number Generators: A New Approach
PPT
Lecture06-Random-Number-Genedawrators.ppt
PPT
RandomNumbers.ppt
PDF
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
PPT
lections tha detail aboot andom nummerss
PDF
Generating random primes
PPTX
Unit-3 of mathematical foundation of ai ml
PDF
Fv2510671071
PDF
PPTX
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
PDF
Random number generation (in C++) – past, present and potential future
PPTX
PDF
Random Number Generator Using Seven Segment Display In Labview
PDF
Random number generator
PPTX
Information and network security 30 random numbers
PPTX
Random number generation
PPTX
MT6702 Unit 2 Random Number Generation
PDF
J45015460
2. Modelling and Simulation in computer 2.pptx
40120140502003
Pseudo-Random Number Generators: A New Approach
Lecture06-Random-Number-Genedawrators.ppt
RandomNumbers.ppt
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
lections tha detail aboot andom nummerss
Generating random primes
Unit-3 of mathematical foundation of ai ml
Fv2510671071
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Random number generation (in C++) – past, present and potential future
Random Number Generator Using Seven Segment Display In Labview
Random number generator
Information and network security 30 random numbers
Random number generation
MT6702 Unit 2 Random Number Generation
J45015460

Recently uploaded (20)

PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
KodekX | Application Modernization Development
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Modernizing your data center with Dell and AMD
PPTX
Cloud computing and distributed systems.
PPTX
A Presentation on Artificial Intelligence
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
The AUB Centre for AI in Media Proposal.docx
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Chapter 3 Spatial Domain Image Processing.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
Spectral efficient network and resource selection model in 5G networks
Review of recent advances in non-invasive hemoglobin estimation
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
20250228 LYD VKU AI Blended-Learning.pptx
Modernizing your data center with Dell and AMD
Cloud computing and distributed systems.
A Presentation on Artificial Intelligence
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology

Pseudorandom number generators powerpoint

  • 2. Part 1: What does “Pseudorandom” mean? The word “Pseudorandom” can be split into these two parts: pseudo, random. The “random” part is self explanatory, but then there is “pseudo.” “Pseudo” implies that it only mimicks randomness. This is often bad for random numbers, but some computer programs require random numbers, such as programs for reaction tests. You don’t want someone to be able to predict what they’re reacting to, and the given output will still be generated by a computer. Computers can’t do better that generate pseudorandom numbers. This presentation is about different simple pseudorandom number generators, and their qualities. The results will be presented via. histogram. One quality of a pseudorandom number generator is that it is equally likely to be any number in a specified range. If you flip a coin several times, it’s equally likely to be either heads or tails. Another quality is how random the changes in the numbers are. If you count 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, the number you count at any given moment is equally likely to be any number from 1 to 10, but it’s still not random.
  • 3. Part 2: How the Difference works Understanding the first quality discussed in this presentation is trivial: The numbers need to be generated about as often as each other. The difference works differently, though. Imagine this: You are rolling a fair die. First, you roll a 1. The next number rolled is equally likely to be any number from 1 to 6. Thus, the difference between 1 and the next number rolled is equally likely to be 0, 1, 2, 3, 4, or 5. We can make a small histogram of this, repeated. For 2, the number can change by -1, 0, 1, 2, 3, or 4. For 3, we have -2, -1, 0, 1, 2, and 3, etc. The histogram would look like this: Now we know what to expect in the difference of the pseudorandom numbers. -5 -4 -3 -2 -1 0 1 2 3 4 5
  • 4. Generator #1 𝑔1 𝑥 ≡ e 𝑥 mod 1 If you take 𝑎 𝑥mod 𝑏, (where both 𝑎 and 𝑏 are integers,) and count 𝑥, then as long as 𝑎 and 𝑏 share no factors, you can get back each number from 1 to 𝑏 − 1 exactly once before you get the same number as before. Thus, modular exponentiation is uniformly distributed. In simpler words, if you multiply a number by itself several times, and subtract another number from it as many times as possible without going below 0, you will get a random number. This is the method I tested here. Based on this, the pseudorandom numbers generated here will be well distributed. The only problem that could happen is if there is a bad distribution of the differences of numbers.
  • 5. Testing Generator #1 As you see below, the distribution of the numbers only has a few bumps in it. The distribution of the differences is also in the triangle shape that we wanted. The only disappointment is that the generator can’t generate many numbers. If you do exactly what the generator says, you can only generate 31 numbers. If you use a simpler way of calculating the numbers, you can generate up to 713 numbers. This is a good pseudorandom number generator, but the calculations are just too much for the computer. = Difference = Numbers Generated
  • 6. Generator #2 𝑔2 𝑥 = sin2 𝑥 This function is basically a wave that goes up and down very quickly. One way to represent this is taking a spring, stretching it, and flattening it sideways. You will see a wave. If you look at the wave, you will see that it stays at either the far top or the far bottom for a bit before it continues. This could cause a problem with the distribution.
  • 7. Testing Generator #2 As expected, the numbers are generated more often on the sides. What’s curious, though, is why the difference in the numbers is always around 0. This means that the number generated slowly travels back and forth, between 1 and 0. = Difference = Numbers Generated
  • 8. Generator #3 Imagine that you spin a spinner, and it keeps spinning forever. It keeps going at the same speed all the time. It takes 10 seconds to make a full rotation, and there are 10 numbers total. Every 7 seconds, you write down what number the spinner is over. This is equally likely to be any number on the spinner. We use this concept in this generator. The only thing that might go wrong is the distribution of the differences. 𝑔3 𝑥 ≡ 𝑒𝑥 mod 1
  • 9. Testing Generator #3 The distribution of the numbers generated is near perfect. The distribution of the differences, though, is a different matter. The difference between the outputs can be exactly one of two numbers. This is a little disappointing, because we were sort of relying on that for this to be a good generator. The last generator wasn’t that good, but at least it could have a difference of more than two numbers. = Difference = Numbers Generated
  • 10. Generator #4 𝑔4 𝑥 ≡ ln 𝑥 mod 1 This generator is (spoiler alert) the worst yet. It is intended, though, because using this, you can see what bad qualities you don’t want to see in a pseudorandom number generator. The difference between the numbers in this generator get smaller and smaller, and it doesn’t even have a distribution. Mathematicians, before you call this bogus, go to https://www.khanacademy.org/cs/pseudorand om-number-generators/4733195911168000, and look for something that says //Change to try different generators. Look to the left of it, and change the number in the brackets to 4. Click restart, and watch.
  • 11. Testing Generator #4 As expected, this wasn’t a very good generator. The distribution of the differences is basically a single spike, The distribution here, if you keep generating numbers, won’t ever stay the same. By this, we can’t tell whether the distribution here is even or spiky. = Difference = Numbers Generated
  • 12. Conclusion It seems that most of these generators are terrible. The best one of them is too tough on the computer, even though it works beautifully. This shows how hard it is to create these generators. One of the best generators used is called the Mersenne Twister. This generator is hard to understand, and involves the distribution of Mersenne Primes. Making these good generators is extremely difficult.