SlideShare a Scribd company logo
RANDOM-NUMBER
GENERATION
BY
S.KANNAPPAN
AP-MTRE
INTRODUCTION
• Random numbers are a necessary basic ingredient in
the simulation of almost all discrete systems.
• Most computer languages have a subroutine, object,
or function that will generate a random number.
• Random numbers that are used to generate event
times and other random variables.
Properties of Random Numbers
• A sequence of random numbers, R1, R2... must
have two important statistical properties,
uniformity and independence.
• Each random number Ri, is an independent
sample drawn from a continuous uniform
distribution between 0 and 1.
Properties of Random Numbers
• That is, the pdf is given by
• The density function is shown below:
Properties of Random Numbers
• Some consequences of the uniformity and independence
properties are :
1. If the interval (0, 1) is divided into n classes, or
subintervals of equal length, the expected number of
observations m each interval is N/n where N is the total
number of observations.
2. The probability of observing a value in a particular
interval is independent of the previous values drawn.
Generation of Pseudo-Random Numbers
• Pseudo means false, so false random numbers
are being generated.
• The goal of any generation scheme, is to produce
a sequence of numbers between zero and 1
• Which simulates, or initiates, the ideal properties
of uniform distribution and independence as
closely as possible.
Generation of Pseudo-Random Numbers
• When generating pseudo-random numbers,
certain problems or errors can occur.
• These errors, or departures from ideal
randomness, are all related to the properties
stated previously.
• Some examples include the following
Generation of Pseudo-Random Numbers
1) The generated numbers may not be uniformly
distributed.
2) The generated numbers may be discrete -valued instead
continuous valued.
3) The mean of the generated numbers may be too high or
too low.
4) The variance of the generated numbers may be too high
or low.
Considerations in RN routine
• The routine should be fast
• The routine should be portable
• The routine should have a sufficiently long cycle
• The random numbers should be replicable.
• Random numbers should closely approximate the
ideal statistical properties of uniformity and
independences
Techniques for Generating Random Numbers
The linear congruential method
• It widely used technique, initially proposed by
Lehmer [1951]
• It produces a sequence of integers, X1, X2,...
Between zero and m — 1 according to the following
recursive relationship:
Xi+1 = (aXi + c) mod m, i = 0, 1, 2....
The linear congruential method
• If c ≠ 0then the form is called mixed congruential
method.
• When c = 0, the form is known as the multiplicative
congruential method.
• The selection of the values for a, c, m and X0
drastically affects the statistical properties and the
cycle length.
Multiplicative Congruential Method:
• Most natural choice for m is one that equals to the
capacity of a computer word.
• m = 2b (binary machine), where b is the number of bits in
the computer word.
• m = 10d (decimal machine), where d is the number of
digits in the computer word.
Xi+1 = a Xi (mod m), where a ≥ 0 and m ≥ 0 …
Tests For Random Numbers
1. Frequency test. Uses the Kolmogorov-Smirnov or the
chi-square test to compare the distribution of the set
of numbers generated to a uniform distribution.
2. Runs test. Tests the runs up and down or the runs
above and below the mean by comparing the actual
values to expected values. The statistic for
comparison is the chi-square.
Tests For Random Numbers
3. Autocorrelation test. Tests the correlation between
numbers and compares the sample correlation to the
expected correlation of zero.
4. Gap test. Counts the number of digits that appear
between repetitions of a particular digit and then
uses the Kolmogorov-Smirnov test to compare with
the expected number of gaps.
Tests For Random Numbers
5. Poker test. Treats numbers grouped together as a
poker hand. Then the hands obtained are compared
to what is expected using the chi-square test.
• In testing for uniformity, the hypotheses are as
follows:
 H0: Ri ~ U[0,1]
 H1: Ri ɫ U[0,1]
Tests For Random Numbers
• The null hypothesis, H0, reads that the numbers are
distributed uniformly on the interval [0, 1].
• In testing for independence, the hypotheses are as
follows
 H0: Ri ~ independently
 H1: Ri ɫ independently
Frequency Tests
• To validate a new generator is the test of uniformity.
• Two types - Kolmogorov-Smirnov and Chi-square test.
• Both measure the degree of agreement between the
distribution of a sample of generated random numbers and
the theoretical uniform distribution.
• Both tests are on the null hypothesis of no significant
difference between the sample distribution and the
theoretical distribution.
The Kolmogorov-Smirnov test
The Kolmogorov-Smirnov test
• Suppose that the five numbers 0.44, 0.81,
0.14, 0.05, 0.93 were generated, and it is
desired to perform a test for uniformity using
the Kolmogorov-Smirnov test with a level of
significance of 0.05.
Chi-Square Test
Use the chi-square test with level of significance 0.05 to
test whether the data shown below are uniformly
distributed. The test uses n = 10 intervals of equal length
Chi-Square Test
Run Test
Run Test
Based on runs up and runs down, determine whether the
following sequence of 40 numbers is such that the hypothesis
of independence can be rejected where a = 0.05.

More Related Content

PDF
Introduction to data analytics
PPTX
Real-time applications of Data Science.pptx
PPTX
Introduction to data science.pptx
PPTX
3 Data Mining Tasks
PPTX
Privacy, security and ethics in data science
PPTX
Machine Learning: Bias and Variance Trade-off
PPTX
Classification and Regression
PDF
Data visualization in Python
Introduction to data analytics
Real-time applications of Data Science.pptx
Introduction to data science.pptx
3 Data Mining Tasks
Privacy, security and ethics in data science
Machine Learning: Bias and Variance Trade-off
Classification and Regression
Data visualization in Python

What's hot (20)

PPTX
Introduction to Information Retrieval
PDF
Bayesian inference
PPTX
Statistics for data science
PDF
Genetic Algorithms
PPTX
Decision tree induction \ Decision Tree Algorithm with Example| Data science
PPTX
Application of data mining
PDF
Lecture1 introduction to big data
PDF
Support Vector Machines ( SVM )
PPTX
Machine learning in healthcare.pptx
PPTX
Data mining presentation.ppt
PPTX
Data extraction, transformation, and loading
PDF
Bayesian networks
PPT
Knowledge discovery thru data mining
PPTX
Lecture-12Evaluation Measures-ML.pptx
PPTX
K-Means Clustering Algorithm.pptx
PDF
Stochastic gradient descent and its tuning
PDF
Linear Regression vs Logistic Regression | Edureka
PDF
The Data Science Process
PDF
Data Visualization in Exploratory Data Analysis
Introduction to Information Retrieval
Bayesian inference
Statistics for data science
Genetic Algorithms
Decision tree induction \ Decision Tree Algorithm with Example| Data science
Application of data mining
Lecture1 introduction to big data
Support Vector Machines ( SVM )
Machine learning in healthcare.pptx
Data mining presentation.ppt
Data extraction, transformation, and loading
Bayesian networks
Knowledge discovery thru data mining
Lecture-12Evaluation Measures-ML.pptx
K-Means Clustering Algorithm.pptx
Stochastic gradient descent and its tuning
Linear Regression vs Logistic Regression | Edureka
The Data Science Process
Data Visualization in Exploratory Data Analysis
Ad

Similar to MT6702 Unit 2 Random Number Generation (20)

PPTX
PPT
Random Number Generation Conceptual and Practice
PPT
Random number generation
PPTX
Unit 3 random number generation, random-variate generation
PPTX
Random number generation
PPSX
Generate and test random numbers
PPTX
Teknik Simulasi
PDF
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
PPTX
Random number generation
PDF
Random number generator
PDF
Cost Optimized Design Technique for Pseudo-Random Numbers in Cellular Automata
PPT
Lecture06-Random-Number-Genedawrators.ppt
PDF
Essentials of monte carlo simulation
PPTX
Testing Numbers for Randomness Chi Square test
PPTX
Pseudo Random Number
PPTX
4. random number and it's generating techniques
PDF
Tools for computational finance
PDF
Uniform and non-uniform pseudo random numbers generators for high dimensional...
PPTX
Pseudorandom number generators powerpoint
Random Number Generation Conceptual and Practice
Random number generation
Unit 3 random number generation, random-variate generation
Random number generation
Generate and test random numbers
Teknik Simulasi
AN ALTERNATIVE APPROACH FOR SELECTION OF PSEUDO RANDOM NUMBERS FOR ONLINE EXA...
Random number generation
Random number generator
Cost Optimized Design Technique for Pseudo-Random Numbers in Cellular Automata
Lecture06-Random-Number-Genedawrators.ppt
Essentials of monte carlo simulation
Testing Numbers for Randomness Chi Square test
Pseudo Random Number
4. random number and it's generating techniques
Tools for computational finance
Uniform and non-uniform pseudo random numbers generators for high dimensional...
Pseudorandom number generators powerpoint
Ad

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
composite construction of structures.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Digital Logic Computer Design lecture notes
PPTX
Sustainable Sites - Green Building Construction
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT
Project quality management in manufacturing
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
UNIT 4 Total Quality Management .pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
PPT on Performance Review to get promotions
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Construction Project Organization Group 2.pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
composite construction of structures.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Digital Logic Computer Design lecture notes
Sustainable Sites - Green Building Construction
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Project quality management in manufacturing
Internet of Things (IOT) - A guide to understanding
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
UNIT 4 Total Quality Management .pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
CH1 Production IntroductoryConcepts.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT on Performance Review to get promotions

MT6702 Unit 2 Random Number Generation

  • 2. INTRODUCTION • Random numbers are a necessary basic ingredient in the simulation of almost all discrete systems. • Most computer languages have a subroutine, object, or function that will generate a random number. • Random numbers that are used to generate event times and other random variables.
  • 3. Properties of Random Numbers • A sequence of random numbers, R1, R2... must have two important statistical properties, uniformity and independence. • Each random number Ri, is an independent sample drawn from a continuous uniform distribution between 0 and 1.
  • 4. Properties of Random Numbers • That is, the pdf is given by • The density function is shown below:
  • 5. Properties of Random Numbers • Some consequences of the uniformity and independence properties are : 1. If the interval (0, 1) is divided into n classes, or subintervals of equal length, the expected number of observations m each interval is N/n where N is the total number of observations. 2. The probability of observing a value in a particular interval is independent of the previous values drawn.
  • 6. Generation of Pseudo-Random Numbers • Pseudo means false, so false random numbers are being generated. • The goal of any generation scheme, is to produce a sequence of numbers between zero and 1 • Which simulates, or initiates, the ideal properties of uniform distribution and independence as closely as possible.
  • 7. Generation of Pseudo-Random Numbers • When generating pseudo-random numbers, certain problems or errors can occur. • These errors, or departures from ideal randomness, are all related to the properties stated previously. • Some examples include the following
  • 8. Generation of Pseudo-Random Numbers 1) The generated numbers may not be uniformly distributed. 2) The generated numbers may be discrete -valued instead continuous valued. 3) The mean of the generated numbers may be too high or too low. 4) The variance of the generated numbers may be too high or low.
  • 9. Considerations in RN routine • The routine should be fast • The routine should be portable • The routine should have a sufficiently long cycle • The random numbers should be replicable. • Random numbers should closely approximate the ideal statistical properties of uniformity and independences
  • 10. Techniques for Generating Random Numbers The linear congruential method • It widely used technique, initially proposed by Lehmer [1951] • It produces a sequence of integers, X1, X2,... Between zero and m — 1 according to the following recursive relationship: Xi+1 = (aXi + c) mod m, i = 0, 1, 2....
  • 11. The linear congruential method • If c ≠ 0then the form is called mixed congruential method. • When c = 0, the form is known as the multiplicative congruential method. • The selection of the values for a, c, m and X0 drastically affects the statistical properties and the cycle length.
  • 12. Multiplicative Congruential Method: • Most natural choice for m is one that equals to the capacity of a computer word. • m = 2b (binary machine), where b is the number of bits in the computer word. • m = 10d (decimal machine), where d is the number of digits in the computer word. Xi+1 = a Xi (mod m), where a ≥ 0 and m ≥ 0 …
  • 13. Tests For Random Numbers 1. Frequency test. Uses the Kolmogorov-Smirnov or the chi-square test to compare the distribution of the set of numbers generated to a uniform distribution. 2. Runs test. Tests the runs up and down or the runs above and below the mean by comparing the actual values to expected values. The statistic for comparison is the chi-square.
  • 14. Tests For Random Numbers 3. Autocorrelation test. Tests the correlation between numbers and compares the sample correlation to the expected correlation of zero. 4. Gap test. Counts the number of digits that appear between repetitions of a particular digit and then uses the Kolmogorov-Smirnov test to compare with the expected number of gaps.
  • 15. Tests For Random Numbers 5. Poker test. Treats numbers grouped together as a poker hand. Then the hands obtained are compared to what is expected using the chi-square test. • In testing for uniformity, the hypotheses are as follows:  H0: Ri ~ U[0,1]  H1: Ri ɫ U[0,1]
  • 16. Tests For Random Numbers • The null hypothesis, H0, reads that the numbers are distributed uniformly on the interval [0, 1]. • In testing for independence, the hypotheses are as follows  H0: Ri ~ independently  H1: Ri ɫ independently
  • 17. Frequency Tests • To validate a new generator is the test of uniformity. • Two types - Kolmogorov-Smirnov and Chi-square test. • Both measure the degree of agreement between the distribution of a sample of generated random numbers and the theoretical uniform distribution. • Both tests are on the null hypothesis of no significant difference between the sample distribution and the theoretical distribution.
  • 19. The Kolmogorov-Smirnov test • Suppose that the five numbers 0.44, 0.81, 0.14, 0.05, 0.93 were generated, and it is desired to perform a test for uniformity using the Kolmogorov-Smirnov test with a level of significance of 0.05.
  • 20. Chi-Square Test Use the chi-square test with level of significance 0.05 to test whether the data shown below are uniformly distributed. The test uses n = 10 intervals of equal length
  • 23. Run Test Based on runs up and runs down, determine whether the following sequence of 40 numbers is such that the hypothesis of independence can be rejected where a = 0.05.