SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Presentation on Pseudo Random-Number
Generation
Contents
• Pseudo-Random Numbers and their properties
• Generating Random Numbers
• Midsquare Method
• Linear Congruential Method
• Combined Linear Congruential Method
• Tests for Random Numbers
Pseudo-Random Numbers
• Approach: Arithmetically generation
(calculation) of random numbers
• “Pseudo”, because generating numbers using a
known method removes the potential for true
randomness.
• Goal: To produce a sequence of numbers in
[0,1] that simulates, or imitates, the ideal
properties of random numbers (RN).
Pseudo-Random Numbers
• Important properties of good random number
routines:
• Fast
• Portable to different computers
• Have sufficiently long cycle
• Replicable
• Verification and debugging
• Use identical stream of random numbers for different
systems
• Closely approximate the ideal statistical properties of
• uniformity and
• independence
Pseudo-Random Numbers:
Properties
• Two important statistical properties:
• Uniformity
• Independence
• Random number Ri must be independently drawn from a
uniform distribution with PDF:
1
22
1
x2
0
1
0
E(R)  xdx  
0 1
PDF for random numbers
f(x)
x
1, 0  x 1
f(x)= 0. otherwise
Generation of Random Numbers
• Midsquare method
• Linear Congruential Method (LCM)
• Combined Linear Congruential Generators (CLCG)
• Random-Number Streams
Midsquare method
• First arithmetic generator: Midsquare method
• von Neumann and Metropolis in 1940s
• The Midsquare method:
• Start with a four-digit positive integer Z0
• Compute: to obtain an integer with up to eight
digits
• Take the middle four digits for the next four-digit number
2
0 0 0Z  Z Z
i Zi Ui Zi×Zi
0 7182 - 51581124
1 5811 0.5811 33767721
2 7677 0.7677 58936329
3 9363 0.9363 87665769
…
Midsquare method
• Problem: Generated
numbers tend to 0
i Zi Ui Zi×Zi
0 7182 - 51581124
1 5811 0,5811 33767721
2 7677 0,7677 58936329
3 9363 0,9363 87665769
4 6657 0,6657 44315649
5 3156 0,3156 09960336
6 9603 0,9603 92217609
7 2176 0,2176 04734976
8 7349 0,7349 54007801
9 78 0,0078 00006084
10 60 0,006 00003600
11 36 0,0036 00001296
12 12 0,0012 00000144
13 1 0,0001 00000001
14 0 0 00000000
15 0 0 00000000
Linear Congruential Method
• To produce a sequence of integers X1, X2, … between 0 and
m-1 by following a recursive relationship:
Xi1  (aXi  c)mod m, i  0,1,2,...
• Assumption: m > 0 and a < m, c < m, X0 < m
• The selection of the values for a, c, m, and X0 drastically
affects the statistical properties and the cycle length
• The random integers Xi are being generated in [0, m-1]
The multiplier The increment The modulus
Linear Congruential Method
• Convert the integers Xi to random numbers
• Note:
• Xi  {0, 1, ...,m-1}
• Ri  [0,(m-1)/m]
, i 1,2,...R 
m
Xi
i
Linear Congruential Method:
Example
• Use X0 = 27, a = 17, c = 43, and m =100.
• The Xi and Ri values are:
X1 = (17×27+43) mod 100 = 502 mod 100 =2 Æ R1 = 0.02
X2 = (17×2 +43) mod 100 = 77 Æ R2 = 0.77
X3 = (17×77+43) mod 100 = 52 Æ R3 = 0.52
X4 = (17×52+43) mod 100 = 27
…
Æ R3 = 0.27
Linear Congruential Method:
Example
• Use a = 13, c = 0, and m = 64
• The period of the
generator is very low
• Seed X0 influences the
sequence
i
Xi
X0=1
Xi
X0=2
Xi
X0=3
Xi
X0=4
0 1 2 3 4
1 13 26 39 52
2 41 18 59 36
3 21 42 63 20
4 17 34 51 4
5 29 58 23
6 57 50 43
7 37 10 47
8 33 2 35
9 45 7
10 9 27
11 53 31
12 49 19
13 61 55
14 25 11
15 5 15
16 1 3
General Congruential
Generators
• Linear Congruential Generators are a special case of
generators defined by:
Xi 1  g(Xi , Xi1,…) mod m
• where g() is a function of previous Xi’s
• Xi  [0, m-1], Ri = Xi /m
• Quadratic congruential generator
• Defined by: g( X , X )  aX 2
 bX  c
i i1 i i1
• Multiple recursive generators
• Defined by: g(Xi , Xi1,…)  a1 Xi  a2 Xi1  ak Xik
• Fibonacci generator
• Defined by: Xi1g(Xi , Xi1)  Xi
Combined Linear Congruential
Generators• Reason: Longer period generator is needed because of the
increasing complexity of simulated systems.
• Approach: Combine two or more multiplicative congruential
generators.
• Let Xi,1, Xi,2, …, Xi,k be the i-th output from k different
multiplicative congruential generators.
• The j-th generator X•,j:
• has prime modulus mj, multiplier aj, and period mj -1
• produces integers Xi,j approx ~ Uniform on [0, mj – 1]
• Wi,j = Xi,j - 1 is approx ~ Uniform on integers on [0, mj -2]
 cj ) mod mjXi1, j  (aj Xi
Tests for Random Numbers
• When to use these tests:
• If a well-known simulation language or random-number generator is
used, it is probably unnecessary to test
• If the generator is not explicitly known or documented, e.g.,
spreadsheet programs, symbolic/numerical calculators, tests should
be applied to many sample numbers.
• Types of tests:
• Theoretical tests: evaluate the choices of m, a, and c without actually
generating any numbers
• Empirical tests: applied to actual sequences of numbers produced.
• Our emphasis.
Kolmogorov-Smirnov Test-
Frequency test• Compares the continuous CDF, F(x), of the uniform distribution
with the empirical CDF, SN(x), of the N sample observations.
• We know:
• If the sample from the RNG
is R1, R2, …, RN, then the empirical
CDF, SN(x) is:
• Based on the statistic: D = max | F(x) - SN(x)|
• Sampling distribution of D is known
F(x)  x, 0  x 1
Number of Ri where Ri  x
NNS (x) 
0 1
F(x)
x
Kolmogorov-Smirnov Test
• The test consists of the
following steps
• Step 1: Rank the data from
smallest to largest
R(1) ≤ R(2) ≤ ... ≤ R(N)
• Step 2: Compute
• Step 3: Compute D = max(D+, D-)
• Step 4: Get D for the
significance level 
• Step 5: If D ≤ D accept,
otherwise reject H0
 N

i 1
D
 maxR 




N
D
 maxi
 R (i) 1iN
(i)
1iN

Kolmogorov-Smirnov Critical Values
Kolmogorov-Smirnov Test
6.18
i/N 0.20 0.40 0.60 0.80 1.00
i/N – R(i) 0.15 0.26 0.16 - 0.07
R(i) –(i-1)/N 0.05 - 0.04 0.21 0.13
Step 2:
Step 3:
Step 4:
D = max(D+, D-) = 0.26
For  = 0.05,
D = 0.565 > D = 0.26
Hence, H0 is not rejected.
i 1 2 3 4 5 Arrange R(i) from
R(i) 0.05 0.14 0.44 0.81 0.93
smallest to largest
• Example: Suppose N=5 numbers: 0.44, 0.81, 0.14, 0.05,0.93.
Step 1:
D+ = max{i/N –R(i)}
D - = max{R(i) -(i-1)/N}
Chi-square Test- Frequency tests
• Chi-square test uses the sample statistic:
• Approximately the chi-square distribution with n-1 degrees of
freedom
• For the uniform distribution, Ei, the expected number in each class
is:
• Valid only for large samples, e.g., N ≥ 50
i1
n
Ei
2
(O  E )2
i i
0  
n
iE 
N
, where N is the total number of observations
Ei is the expected # in the i-th class
Oi is the observed # in the i-th classn is the # of classes
Chi-square Test:
Example
Interval Upper Limit Oi Ei Oi-Ei (Oi-Ei)^2 (Oi-Ei)^2/Ei
1 0.1 10 10 0 0 0
2 0.2 9 10 -1 1 0.1
3 0.3 5 10 -5 25 2.5
4 0.4 6 10 -4 16 1.6
5 0.5 16 10 6 36 3.6
6 0.6 13 10 3 9 0.9
7 0.7 10 10 0 0 0
8 0.8 7 10 -3 9 0.9
9 0.9 10 10 0 0 0
10 1.0 14 10 4 16 1.6
Sum 100 100 0 0 11.2
• Example with 100 numbers from [0,1], =0.05
• 10 intervals
0.05,9•  2 = 16.9
• Accept, since
0• X2 =11.2 <  2
0.05,9
0X2 =11.2
n
Eii1
2
(O  E)2
i i
0 

Weitere ähnliche Inhalte

Was ist angesagt?

Lecture: Monte Carlo Methods
Lecture: Monte Carlo MethodsLecture: Monte Carlo Methods
Lecture: Monte Carlo MethodsFrank Kienle
 
The monte carlo method
The monte carlo methodThe monte carlo method
The monte carlo methodSaurabh Sood
 
Monte Carlo Simulations
Monte Carlo SimulationsMonte Carlo Simulations
Monte Carlo Simulationsgfbreaux
 
Probability distribution in R
Probability distribution in RProbability distribution in R
Probability distribution in RAlichy Sowmya
 
Basic probability concept
Basic probability conceptBasic probability concept
Basic probability conceptMmedsc Hahm
 
conditional probabilty
conditional probabiltyconditional probabilty
conditional probabiltylovemucheca
 
Unit 2 monte carlo simulation
Unit 2 monte carlo simulationUnit 2 monte carlo simulation
Unit 2 monte carlo simulationDevaKumari Vijay
 
Exponential probability distribution
Exponential probability distributionExponential probability distribution
Exponential probability distributionMuhammad Bilal Tariq
 
Gomory's cutting plane method
Gomory's cutting plane methodGomory's cutting plane method
Gomory's cutting plane methodRajesh Piryani
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data AnalyticsSSaudia
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statisticsRajendran
 
Chp. 2 simulation examples
Chp. 2 simulation examplesChp. 2 simulation examples
Chp. 2 simulation examplesPravesh Negi
 
Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix Nick Trott
 
Geometric Distribution
Geometric DistributionGeometric Distribution
Geometric DistributionRatul Basak
 
Probability Distribution
Probability DistributionProbability Distribution
Probability DistributionSarabjeet Kaur
 

Was ist angesagt? (20)

Lecture: Monte Carlo Methods
Lecture: Monte Carlo MethodsLecture: Monte Carlo Methods
Lecture: Monte Carlo Methods
 
The monte carlo method
The monte carlo methodThe monte carlo method
The monte carlo method
 
Monte Carlo Simulations
Monte Carlo SimulationsMonte Carlo Simulations
Monte Carlo Simulations
 
Probability distribution in R
Probability distribution in RProbability distribution in R
Probability distribution in R
 
Basic probability concept
Basic probability conceptBasic probability concept
Basic probability concept
 
conditional probabilty
conditional probabiltyconditional probabilty
conditional probabilty
 
Probability Distribution
Probability DistributionProbability Distribution
Probability Distribution
 
Unit 2 monte carlo simulation
Unit 2 monte carlo simulationUnit 2 monte carlo simulation
Unit 2 monte carlo simulation
 
Exponential probability distribution
Exponential probability distributionExponential probability distribution
Exponential probability distribution
 
03 Machine Learning Linear Algebra
03 Machine Learning Linear Algebra03 Machine Learning Linear Algebra
03 Machine Learning Linear Algebra
 
Gomory's cutting plane method
Gomory's cutting plane methodGomory's cutting plane method
Gomory's cutting plane method
 
Simulation Powerpoint- Lecture Notes
Simulation Powerpoint- Lecture NotesSimulation Powerpoint- Lecture Notes
Simulation Powerpoint- Lecture Notes
 
Probability concepts for Data Analytics
Probability concepts for Data AnalyticsProbability concepts for Data Analytics
Probability concepts for Data Analytics
 
Medians and order statistics
Medians and order statisticsMedians and order statistics
Medians and order statistics
 
Chp. 2 simulation examples
Chp. 2 simulation examplesChp. 2 simulation examples
Chp. 2 simulation examples
 
Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix Mathematics Foundation Course for Machine Learning & AI By Eduonix
Mathematics Foundation Course for Machine Learning & AI By Eduonix
 
Geometric Distribution
Geometric DistributionGeometric Distribution
Geometric Distribution
 
Probability Distribution
Probability DistributionProbability Distribution
Probability Distribution
 
Random Number Generation
Random Number GenerationRandom Number Generation
Random Number Generation
 
Sampling Distributions and Estimators
Sampling Distributions and Estimators Sampling Distributions and Estimators
Sampling Distributions and Estimators
 

Ähnlich wie Random number generation

4. random number and it's generating techniques
4. random number and it's generating techniques 4. random number and it's generating techniques
4. random number and it's generating techniques MdFazleRabbi18
 
MT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number GenerationMT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number GenerationKannappan Subramaniam
 
Random Number Generator.pdf
Random Number Generator.pdfRandom Number Generator.pdf
Random Number Generator.pdfDedy PrasTyo
 
ch09-Simulation.ppt
ch09-Simulation.pptch09-Simulation.ppt
ch09-Simulation.pptLuckySaigon1
 
Sampling_WCSMO_2013_Jun
Sampling_WCSMO_2013_JunSampling_WCSMO_2013_Jun
Sampling_WCSMO_2013_JunMDO_Lab
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................nourhandardeer3
 
슬로우캠퍼스: scikit-learn & 머신러닝 (강박사)
슬로우캠퍼스:  scikit-learn & 머신러닝 (강박사)슬로우캠퍼스:  scikit-learn & 머신러닝 (강박사)
슬로우캠퍼스: scikit-learn & 머신러닝 (강박사)마이캠퍼스
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning IntroductionKuppusamy P
 
604_multiplee.ppt
604_multiplee.ppt604_multiplee.ppt
604_multiplee.pptRufesh
 
More investment in Research and Development for better Education in the future?
More investment in Research and Development for better Education in the future?More investment in Research and Development for better Education in the future?
More investment in Research and Development for better Education in the future?Dhafer Malouche
 
Statr sessions 9 to 10
Statr sessions 9 to 10Statr sessions 9 to 10
Statr sessions 9 to 10Ruru Chowdhury
 

Ähnlich wie Random number generation (20)

4. random number and it's generating techniques
4. random number and it's generating techniques 4. random number and it's generating techniques
4. random number and it's generating techniques
 
MT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number GenerationMT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number Generation
 
Random Number Generator.pdf
Random Number Generator.pdfRandom Number Generator.pdf
Random Number Generator.pdf
 
Mit6 094 iap10_lec03
Mit6 094 iap10_lec03Mit6 094 iap10_lec03
Mit6 094 iap10_lec03
 
ch09-Simulation.ppt
ch09-Simulation.pptch09-Simulation.ppt
ch09-Simulation.ppt
 
Sampling_WCSMO_2013_Jun
Sampling_WCSMO_2013_JunSampling_WCSMO_2013_Jun
Sampling_WCSMO_2013_Jun
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
 
Lec08 fitting
Lec08 fittingLec08 fitting
Lec08 fitting
 
슬로우캠퍼스: scikit-learn & 머신러닝 (강박사)
슬로우캠퍼스:  scikit-learn & 머신러닝 (강박사)슬로우캠퍼스:  scikit-learn & 머신러닝 (강박사)
슬로우캠퍼스: scikit-learn & 머신러닝 (강박사)
 
06.pdf
06.pdf06.pdf
06.pdf
 
Week08.pdf
Week08.pdfWeek08.pdf
Week08.pdf
 
Teknik Simulasi
Teknik SimulasiTeknik Simulasi
Teknik Simulasi
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Ppt
PptPpt
Ppt
 
604_multiplee.ppt
604_multiplee.ppt604_multiplee.ppt
604_multiplee.ppt
 
More investment in Research and Development for better Education in the future?
More investment in Research and Development for better Education in the future?More investment in Research and Development for better Education in the future?
More investment in Research and Development for better Education in the future?
 
SMS Module-4(theory) ppt.pptx
SMS Module-4(theory) ppt.pptxSMS Module-4(theory) ppt.pptx
SMS Module-4(theory) ppt.pptx
 
Statr sessions 9 to 10
Statr sessions 9 to 10Statr sessions 9 to 10
Statr sessions 9 to 10
 
Pseudo Random Number
Pseudo Random NumberPseudo Random Number
Pseudo Random Number
 
BIIntro.ppt
BIIntro.pptBIIntro.ppt
BIIntro.ppt
 

Kürzlich hochgeladen

Call Girls Cuttack Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Cuttack Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Cuttack Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Cuttack Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...narwatsonia7
 
VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...
VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...
VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...narwatsonia7
 
Call Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...Taniya Sharma
 
Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...
Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...
Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...hotbabesbook
 
Call Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore EscortsCall Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escortsvidya singh
 
Russian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls Jaipur
Russian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls JaipurRussian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls Jaipur
Russian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls Jaipurparulsinha
 
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls AvailableVip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls AvailableNehru place Escorts
 
Call Girls Dehradun Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Dehradun Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Dehradun Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Dehradun Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
VIP Call Girls Indore Kirti 💚😋 9256729539 🚀 Indore Escorts
VIP Call Girls Indore Kirti 💚😋  9256729539 🚀 Indore EscortsVIP Call Girls Indore Kirti 💚😋  9256729539 🚀 Indore Escorts
VIP Call Girls Indore Kirti 💚😋 9256729539 🚀 Indore Escortsaditipandeya
 
Chandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD availableChandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD availableDipal Arora
 
Call Girls Varanasi Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Varanasi Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Varanasi Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Varanasi Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...Taniya Sharma
 
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...chandars293
 
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...astropune
 

Kürzlich hochgeladen (20)

Call Girls Cuttack Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Cuttack Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Cuttack Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Cuttack Just Call 9907093804 Top Class Call Girl Service Available
 
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...
 
VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...
VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...
VIP Call Girls Tirunelveli Aaradhya 8250192130 Independent Escort Service Tir...
 
Call Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Coimbatore Just Call 9907093804 Top Class Call Girl Service Available
 
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
 
Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...
Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...
Night 7k to 12k Chennai City Center Call Girls 👉👉 7427069034⭐⭐ 100% Genuine E...
 
Call Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore EscortsCall Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
 
Russian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls Jaipur
Russian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls JaipurRussian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls Jaipur
Russian Call Girls in Jaipur Riya WhatsApp ❤8445551418 VIP Call Girls Jaipur
 
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls AvailableVip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
 
Call Girls Dehradun Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Dehradun Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Dehradun Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Dehradun Just Call 9907093804 Top Class Call Girl Service Available
 
VIP Call Girls Indore Kirti 💚😋 9256729539 🚀 Indore Escorts
VIP Call Girls Indore Kirti 💚😋  9256729539 🚀 Indore EscortsVIP Call Girls Indore Kirti 💚😋  9256729539 🚀 Indore Escorts
VIP Call Girls Indore Kirti 💚😋 9256729539 🚀 Indore Escorts
 
Chandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD availableChandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD available
 
Call Girls Varanasi Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Varanasi Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Varanasi Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Varanasi Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
 
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
 
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
 
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
 
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
 
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
 

Random number generation

  • 1. Presentation on Pseudo Random-Number Generation
  • 2. Contents • Pseudo-Random Numbers and their properties • Generating Random Numbers • Midsquare Method • Linear Congruential Method • Combined Linear Congruential Method • Tests for Random Numbers
  • 3. Pseudo-Random Numbers • Approach: Arithmetically generation (calculation) of random numbers • “Pseudo”, because generating numbers using a known method removes the potential for true randomness. • Goal: To produce a sequence of numbers in [0,1] that simulates, or imitates, the ideal properties of random numbers (RN).
  • 4. Pseudo-Random Numbers • Important properties of good random number routines: • Fast • Portable to different computers • Have sufficiently long cycle • Replicable • Verification and debugging • Use identical stream of random numbers for different systems • Closely approximate the ideal statistical properties of • uniformity and • independence
  • 5. Pseudo-Random Numbers: Properties • Two important statistical properties: • Uniformity • Independence • Random number Ri must be independently drawn from a uniform distribution with PDF: 1 22 1 x2 0 1 0 E(R)  xdx   0 1 PDF for random numbers f(x) x 1, 0  x 1 f(x)= 0. otherwise
  • 6. Generation of Random Numbers • Midsquare method • Linear Congruential Method (LCM) • Combined Linear Congruential Generators (CLCG) • Random-Number Streams
  • 7. Midsquare method • First arithmetic generator: Midsquare method • von Neumann and Metropolis in 1940s • The Midsquare method: • Start with a four-digit positive integer Z0 • Compute: to obtain an integer with up to eight digits • Take the middle four digits for the next four-digit number 2 0 0 0Z  Z Z i Zi Ui Zi×Zi 0 7182 - 51581124 1 5811 0.5811 33767721 2 7677 0.7677 58936329 3 9363 0.9363 87665769 …
  • 8. Midsquare method • Problem: Generated numbers tend to 0 i Zi Ui Zi×Zi 0 7182 - 51581124 1 5811 0,5811 33767721 2 7677 0,7677 58936329 3 9363 0,9363 87665769 4 6657 0,6657 44315649 5 3156 0,3156 09960336 6 9603 0,9603 92217609 7 2176 0,2176 04734976 8 7349 0,7349 54007801 9 78 0,0078 00006084 10 60 0,006 00003600 11 36 0,0036 00001296 12 12 0,0012 00000144 13 1 0,0001 00000001 14 0 0 00000000 15 0 0 00000000
  • 9. Linear Congruential Method • To produce a sequence of integers X1, X2, … between 0 and m-1 by following a recursive relationship: Xi1  (aXi  c)mod m, i  0,1,2,... • Assumption: m > 0 and a < m, c < m, X0 < m • The selection of the values for a, c, m, and X0 drastically affects the statistical properties and the cycle length • The random integers Xi are being generated in [0, m-1] The multiplier The increment The modulus
  • 10. Linear Congruential Method • Convert the integers Xi to random numbers • Note: • Xi  {0, 1, ...,m-1} • Ri  [0,(m-1)/m] , i 1,2,...R  m Xi i
  • 11. Linear Congruential Method: Example • Use X0 = 27, a = 17, c = 43, and m =100. • The Xi and Ri values are: X1 = (17×27+43) mod 100 = 502 mod 100 =2 Æ R1 = 0.02 X2 = (17×2 +43) mod 100 = 77 Æ R2 = 0.77 X3 = (17×77+43) mod 100 = 52 Æ R3 = 0.52 X4 = (17×52+43) mod 100 = 27 … Æ R3 = 0.27
  • 12. Linear Congruential Method: Example • Use a = 13, c = 0, and m = 64 • The period of the generator is very low • Seed X0 influences the sequence i Xi X0=1 Xi X0=2 Xi X0=3 Xi X0=4 0 1 2 3 4 1 13 26 39 52 2 41 18 59 36 3 21 42 63 20 4 17 34 51 4 5 29 58 23 6 57 50 43 7 37 10 47 8 33 2 35 9 45 7 10 9 27 11 53 31 12 49 19 13 61 55 14 25 11 15 5 15 16 1 3
  • 13. General Congruential Generators • Linear Congruential Generators are a special case of generators defined by: Xi 1  g(Xi , Xi1,…) mod m • where g() is a function of previous Xi’s • Xi  [0, m-1], Ri = Xi /m • Quadratic congruential generator • Defined by: g( X , X )  aX 2  bX  c i i1 i i1 • Multiple recursive generators • Defined by: g(Xi , Xi1,…)  a1 Xi  a2 Xi1  ak Xik • Fibonacci generator • Defined by: Xi1g(Xi , Xi1)  Xi
  • 14. Combined Linear Congruential Generators• Reason: Longer period generator is needed because of the increasing complexity of simulated systems. • Approach: Combine two or more multiplicative congruential generators. • Let Xi,1, Xi,2, …, Xi,k be the i-th output from k different multiplicative congruential generators. • The j-th generator X•,j: • has prime modulus mj, multiplier aj, and period mj -1 • produces integers Xi,j approx ~ Uniform on [0, mj – 1] • Wi,j = Xi,j - 1 is approx ~ Uniform on integers on [0, mj -2]  cj ) mod mjXi1, j  (aj Xi
  • 15. Tests for Random Numbers • When to use these tests: • If a well-known simulation language or random-number generator is used, it is probably unnecessary to test • If the generator is not explicitly known or documented, e.g., spreadsheet programs, symbolic/numerical calculators, tests should be applied to many sample numbers. • Types of tests: • Theoretical tests: evaluate the choices of m, a, and c without actually generating any numbers • Empirical tests: applied to actual sequences of numbers produced. • Our emphasis.
  • 16. Kolmogorov-Smirnov Test- Frequency test• Compares the continuous CDF, F(x), of the uniform distribution with the empirical CDF, SN(x), of the N sample observations. • We know: • If the sample from the RNG is R1, R2, …, RN, then the empirical CDF, SN(x) is: • Based on the statistic: D = max | F(x) - SN(x)| • Sampling distribution of D is known F(x)  x, 0  x 1 Number of Ri where Ri  x NNS (x)  0 1 F(x) x
  • 17. Kolmogorov-Smirnov Test • The test consists of the following steps • Step 1: Rank the data from smallest to largest R(1) ≤ R(2) ≤ ... ≤ R(N) • Step 2: Compute • Step 3: Compute D = max(D+, D-) • Step 4: Get D for the significance level  • Step 5: If D ≤ D accept, otherwise reject H0  N  i 1 D  maxR      N D  maxi  R (i) 1iN (i) 1iN  Kolmogorov-Smirnov Critical Values
  • 18. Kolmogorov-Smirnov Test 6.18 i/N 0.20 0.40 0.60 0.80 1.00 i/N – R(i) 0.15 0.26 0.16 - 0.07 R(i) –(i-1)/N 0.05 - 0.04 0.21 0.13 Step 2: Step 3: Step 4: D = max(D+, D-) = 0.26 For  = 0.05, D = 0.565 > D = 0.26 Hence, H0 is not rejected. i 1 2 3 4 5 Arrange R(i) from R(i) 0.05 0.14 0.44 0.81 0.93 smallest to largest • Example: Suppose N=5 numbers: 0.44, 0.81, 0.14, 0.05,0.93. Step 1: D+ = max{i/N –R(i)} D - = max{R(i) -(i-1)/N}
  • 19. Chi-square Test- Frequency tests • Chi-square test uses the sample statistic: • Approximately the chi-square distribution with n-1 degrees of freedom • For the uniform distribution, Ei, the expected number in each class is: • Valid only for large samples, e.g., N ≥ 50 i1 n Ei 2 (O  E )2 i i 0   n iE  N , where N is the total number of observations Ei is the expected # in the i-th class Oi is the observed # in the i-th classn is the # of classes
  • 20. Chi-square Test: Example Interval Upper Limit Oi Ei Oi-Ei (Oi-Ei)^2 (Oi-Ei)^2/Ei 1 0.1 10 10 0 0 0 2 0.2 9 10 -1 1 0.1 3 0.3 5 10 -5 25 2.5 4 0.4 6 10 -4 16 1.6 5 0.5 16 10 6 36 3.6 6 0.6 13 10 3 9 0.9 7 0.7 10 10 0 0 0 8 0.8 7 10 -3 9 0.9 9 0.9 10 10 0 0 0 10 1.0 14 10 4 16 1.6 Sum 100 100 0 0 11.2 • Example with 100 numbers from [0,1], =0.05 • 10 intervals 0.05,9•  2 = 16.9 • Accept, since 0• X2 =11.2 <  2 0.05,9 0X2 =11.2 n Eii1 2 (O  E)2 i i 0 