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

What's hot (15)

PPTX
Unit 3 random number generation, random-variate generation
raksharao
 
PPT
Monte Carlo Simulation Of Heston Model In Matlab(1)
Amir Kheirollah
 
PPTX
The monte carlo method
Saurabh Sood
 
PDF
High Dimensional Quasi Monte Carlo Method in Finance
Marco Bianchetti
 
PPT
Monte carlo integration, importance sampling, basic idea of markov chain mont...
BIZIMANA Appolinaire
 
PPTX
Understanding Statistics 2#2 The Normal Probability Distribution
Florin Neagu
 
PPT
Monte carlo
shishirkawde
 
PPTX
Monte carlo simulation
Anurag Jaiswal
 
PPTX
My Math Project
du004008
 
PDF
Lecture: Monte Carlo Methods
Frank Kienle
 
PDF
The use of Monte Carlo simulation in quantitative risk assessment of IT projects
Eswar Publications
 
PDF
model simulating
FEG
 
PDF
Smart Attacks on the integrity of the Internet of Things Avoiding detection b...
Communication Systems & Networks
 
PPS
Innovative Combat By Stoutheart
dkappes
 
PDF
Applied 40S March 3, 2009
Darren Kuropatwa
 
Unit 3 random number generation, random-variate generation
raksharao
 
Monte Carlo Simulation Of Heston Model In Matlab(1)
Amir Kheirollah
 
The monte carlo method
Saurabh Sood
 
High Dimensional Quasi Monte Carlo Method in Finance
Marco Bianchetti
 
Monte carlo integration, importance sampling, basic idea of markov chain mont...
BIZIMANA Appolinaire
 
Understanding Statistics 2#2 The Normal Probability Distribution
Florin Neagu
 
Monte carlo
shishirkawde
 
Monte carlo simulation
Anurag Jaiswal
 
My Math Project
du004008
 
Lecture: Monte Carlo Methods
Frank Kienle
 
The use of Monte Carlo simulation in quantitative risk assessment of IT projects
Eswar Publications
 
model simulating
FEG
 
Smart Attacks on the integrity of the Internet of Things Avoiding detection b...
Communication Systems & Networks
 
Innovative Combat By Stoutheart
dkappes
 
Applied 40S March 3, 2009
Darren Kuropatwa
 

Viewers also liked (6)

PPT
Simulation in terminated system
Saleem Almaqashi
 
PPT
Random variate generation
De La Salle University-Manila
 
PDF
Pseudo Random Number Generators
Darshini Parikh
 
PPTX
Random Number Generation
Raj Bhatt
 
PPSX
Generate and test random numbers
Mshari Alabdulkarim
 
Simulation in terminated system
Saleem Almaqashi
 
Random variate generation
De La Salle University-Manila
 
Pseudo Random Number Generators
Darshini Parikh
 
Random Number Generation
Raj Bhatt
 
Generate and test random numbers
Mshari Alabdulkarim
 
Ad

Similar to Pseudorandom number generators powerpoint (20)

PPTX
2. Modelling and Simulation in computer 2.pptx
waleedhayyakallah
 
PDF
40120140502003
IAEME Publication
 
PDF
Pseudo-Random Number Generators: A New Approach
Nithin Prince John
 
PPT
Lecture06-Random-Number-Genedawrators.ppt
snhskale
 
PPT
RandomNumbers.ppt
noname387448
 
PDF
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
cscpconf
 
PPT
lections tha detail aboot andom nummerss
SandeshStha2
 
PDF
Generating random primes
John-André Bjørkhaug
 
PPTX
Unit-3 of mathematical foundation of ai ml
nikutiwari70
 
PDF
Fv2510671071
IJERA Editor
 
PDF
Non sequitur
Javier Jair Trejo García
 
PPTX
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Codemotion
 
PDF
Random number generation (in C++) – past, present and potential future
Pattabi Raman
 
PPTX
Ppt
Amit Agarwal
 
PDF
Random Number Generator Using Seven Segment Display In Labview
IJERA Editor
 
PDF
Random number generator
Syed Atif Naseem
 
PPTX
Information and network security 30 random numbers
Vaibhav Khanna
 
PPTX
Random number generation
Vinit Dantkale
 
PPTX
MT6702 Unit 2 Random Number Generation
Kannappan Subramaniam
 
PDF
J45015460
IJERA Editor
 
2. Modelling and Simulation in computer 2.pptx
waleedhayyakallah
 
40120140502003
IAEME Publication
 
Pseudo-Random Number Generators: A New Approach
Nithin Prince John
 
Lecture06-Random-Number-Genedawrators.ppt
snhskale
 
RandomNumbers.ppt
noname387448
 
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
cscpconf
 
lections tha detail aboot andom nummerss
SandeshStha2
 
Generating random primes
John-André Bjørkhaug
 
Unit-3 of mathematical foundation of ai ml
nikutiwari70
 
Fv2510671071
IJERA Editor
 
Amanda Sopkin - Computational Randomness: Creating Chaos in an Ordered Machin...
Codemotion
 
Random number generation (in C++) – past, present and potential future
Pattabi Raman
 
Random Number Generator Using Seven Segment Display In Labview
IJERA Editor
 
Random number generator
Syed Atif Naseem
 
Information and network security 30 random numbers
Vaibhav Khanna
 
Random number generation
Vinit Dantkale
 
MT6702 Unit 2 Random Number Generation
Kannappan Subramaniam
 
J45015460
IJERA Editor
 
Ad

Recently uploaded (20)

PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Are there government-backed agri-software initiatives in Limerick.pdf
giselawagner2
 
PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
Upgrading to z_OS V2R4 Part 01 of 02.pdf
Flavio787771
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PDF
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Are there government-backed agri-software initiatives in Limerick.pdf
giselawagner2
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Upgrading to z_OS V2R4 Part 01 of 02.pdf
Flavio787771
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 

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.