SlideShare a Scribd company logo
Random-Number Generation,
Random-Variate Generation
Unit 3
contents
• Random number generation
• Properties of random numbers
• Generation of pseudo-random numbers
• Techniques for generating random numbers
• Tests for Random Numbers
• Random-Variate Generation:
• Inverse transform technique
• Acceptance-Rejection technique
• Special properties
2
Random-Number Generation
Properties of random numbers
• the main properties of random numbers are
• Uniformity
• Independence
• Maximum density
• Maximum period
• Maximum density means that the gaps between random numbers
should not be large, can be achieved by having maximum period.
• Maximum period refers the length of the sequence of random
numbers which are going to repeat after a certain random numbers.
4
• Each random number Ri must be an independent sample drawn from
a continuous uniform distribution between zero and 1
• The pdf of the given by
• f(x)=
1 , 0 ≤ 𝑥 ≤ 1
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
• The expected value of each is given by
• E( R) = 0
1
𝑥 𝑑𝑥 =
1
2
5
• The variance is given by
• V( R) = 0
1
𝑥2
− [𝐸 𝑅 ]2
=
1
12
• The following figure shows the pdf for random numbers
6
Generation of pseudo Random Numbers
• Pseudo means false , here it implies generating random numbers by
known method to remove the potential for true randomness.
• If the method is known then set of random numbers can be repeated.
• Which means that numbers are not random
• The main goal of random generation technique is to produce a
sequence of numbers between 0 and 1 that simulates or imitates the
ideal properties of uniform distribution and independence
• Random numbers are generated by digital computer as part of
simulation, there are numerous ways to generate these values
7
• The following are few important considerations
• The method should be fast, simulation process requires millions of random
numbers hence it has to be fast
• The method has to be portable to different computer
• The method should have sufficiently long cycle, means there should be long
gap between the random numbers once generated getting repeated.
• The random numbers should be repeatable
• The generated random numbers should closely approximate the ideal
statistical properties of uniformity and independence
8
Errors or departures of pseudo random
numbers
• The generated random numbers might not be uniformly distributed.
• Generated numbers might be discrete value instead of continuous
value.
• The mean of generated random numbers might be too high or too
low
• The variance of generated numbers might be too high or too low
• There might be dependence
• Authentication between numbers
• Numbers successively higher or lower than adjacent numbers
• Several numbers above the mean followed by several numbers below the
mean.
9
Techniques for generating random numbers
• Linear congruential method
• Combined linear congruential generators
• Random number streams
10
Linear congruential method
• Proposed by Lehmer, produces a sequences of integer numbers X1,X2 ,
… between zero and m-1 by following the recursive relationship:
• X i+1= (aXi+c) mod m, i=0,1,2,3…
• The initial value i.e. x0 is called seed
• a is called multiplier
• c is called the increment
• m is called the modulus
11
• If c ≠ 𝟎 then form is called mixed congruential method
• When c=0, the form is called multiplicative congruential method
• The selection of the values for a, c, m and X0 affects the statistical
properties and the cycle length.
• Random numbers Ri between 0 and 1 can be generated by setting
• Ri =
𝑿 𝒊
𝒎
, i=1,2,…
12
examples
13
Combined linear congruential generators
• Combine two or more multiplicative congruential generators in such a
way that the combined generator has good statistical properties and
longer period.
• The following result from L’ Ecuyer suggest how this can be done:
14
Combined linear congruential
generators
15
Combined linear congruential generators
• The maximum possible period is given by
16
examples
17
Tests for random numbers
• Number of tests are performed to check the uniformity and independence
of random numbers
• Two types of tests are
• Frequency test : compares the distribution of the set of numbers
generated to a uniform distribution. Few are:
• Kolmogorov-Smirnov Test
• Chi-square Test
• Autocorrelation test: tests the correlation between the two numbers and
compares the sample correlation to the desired correlation, zero
• Runs test
• Gap test
• Pokers test
18
Kolmogorov- Smirnov Test –for uniformity (Procedure)
1. Formulate the hypothesis
H0:Ri ~U[0,1]
H1:Ri ~U[0,1]
2. Rank the data from smallest to largest
R(1)≤R(2) ≤R(3)…
3. Calculate the values of D+ and D-
19
4. Find D=max(D+,D-)
5. Find the critical value Dα from the K-S table
6. If D> Dα then
reject the hypothesis H0
else If D < Dα then
accept the hypothesis H0
20
K-S TABLE
21
examples
22
Chi-square Test –for uniformity (Procedure)
1. Formulate the hypothesis
H0:Ri ~U[0,1]
H1:Ri ~U[0,1]
2. Divide the data into different class intervals of equal intervals
3. Find out how many random numbers lie in each interval and hence find Oi
(observed frequency) & expected frequency Ei using the formula
Ei =
𝑁
𝑛
where N is the total no of observation
n is the no of class interval
L=n-1 is known as degree of freedom
23
4. Calculate
24
Chi-Square table
25
examples
26
Tests for autocorrelation (Test for
independence of random numbers)
• The test for autocorrelation are concerned with the dependence
between numbers in a sequence.
• The autocorrelation between every m numbers starting with ith
number i.e. Ri,Ri+m,Ri+2m, … , Ri+(m+1)m is ρ im
• The value M is the largest integer such that i+(m+1)≤N where N is
the total number of values in the sequence
• A non-zero autocorrelation implies a lack of independence
H0: ρ im = 0
H1: ρ im ≠ 0
27
• For large value of M, the distribution of the estimator of ρ im is
denoted as ρ im
• the test statistics is as follows
• Which is distributed normally with a mean of 0 and variance of
28
• And standard deviation of
29
• After computing Z0, do not reject the null hypothesis of independence
if
• −𝑧 𝛼
2
≤ Z0 ≤ 𝑧 𝛼
2
where is the level of significance and
• 𝑧 𝛼
2
is obtained from a following table A-3
30
Runs test
• Definition: The runs test is defined as sequence of similar preceded
and followed by different events
• Eg. Suppose tossing a coin 10 times results in the following sequence
• H H T T T H T H T T
• Here are 6 runs, first one of length 2, 2nd length of 3, 3rd ,4th ,5th of
length 1 and 6th of length 2
• Two points to be considered while performing runs test
• No of runs
• Length of each run
31
Runs up and runs down
32
• A run is said to be up if its followed by a bigger number and down if
the number is followed by a smaller number
• Since last number is not followed by any number, the maximum
number of runs is n-1 where n is the number of observation
• Procedure of the runs up and runs down is as follows
• Step 1 :
H0: Ri is independent
H1: Ri is not independent
• Step 2: find runs up and runs down by assigning the + sign to every
random number that is followed by bigger number and – sign to a
number that is followed by a smaller number
• Step 3: find the total number of runs (a)
• Step 4: calculate 𝑍 =
𝑎−𝜇 𝑎
𝜎 𝑎
where 𝜇 𝑎=(2N-1)/3 and
𝜎 𝑎=sqrt((16N-29)/90) where N is total number of observation
• Step 5: find the critical value 𝑧 𝛼
2
from the normal table
• Step 6: reject H0 if |Z|≥ 𝑧 𝛼
2
otherwise accept H0
33
examples
34
Random-Variate Generation
Inverse-transform technique
• It can be used to sample from the exponential , uniform, Weibull and
triangular distributions and from empirical distributions.
• Underlying principle for sampling from a wide variety of discrete
distributions.
• Most straightforward but not always efficient technique. Few are
• Exponential distribution
• Uniform distribution
• Weibull distribution
• Triangular distribution
• Empirical discrete distribution
• Discrete uniform distribution
• Geometric distribution
36
Exponential distribution
• Probability density function (pdf) is given by
• 𝑓 𝑥 = λ𝑒−λ𝑥 , 𝑥 ≥ 0
0, 𝑥 < 0
• The cumulative distribution function (cdf) is given by
• F(x)= −∞
𝑥
𝑓 𝑡 𝑑𝑡 = 1 − 𝑒−λ𝑥, 𝑥 ≥ 0
0 , 𝑥 < 0
37
Procedure for inverse transform technique
38
39
40
examples
41
Uniform distribution
• Consider a random variable X i.e. uniformly distributed on the interval
[a,b].
• Step 1 : the cdf is given by
F(x) =
0, 𝑥 < 𝑎
𝑥−𝑎
𝑏−𝑎
, 𝑎 ≤ 𝑥 ≤ 𝑏
1, 𝑥 > 𝑏
• Step 2: Set F(x)=
𝑥−𝑎
𝑏−𝑎
= R
• Step 3: on solving we get , X=a+(b-a)R which is the equation for
random variate generation using uniform distribution
42
Weibull distribution
• The pdf is given
43
Triangular distribution
44
45
examples
46
A discrete
uniform
distribution
47
48
Geometric
distribution
49
50
51
Acceptance – rejection technique
• Devising a method for generating random numbers ‘X’ uniformly
distributed between ¼ and 1 follows three steps
1. Generate a random number R
2. a) If R ≥ ¼ accept X=R the goto step 3
2. b) if R < ¼ reject R and return to step 1
3. If another uniform random variate on [1/4,1] is needed, repeat the
procedure beginning at step 1 , if not stop.
52
Poisson distribution
• Step 1 : Set n=0, P=1
• Step 2 : generate a random number Rn+1 , replace P by P.Rn+1
• Step 3: If P < 𝑒−𝛼
then accept N=n, otherwise reject the current n, increase n by
one and return to step 2
• With N=n poison of average number is given by
E(N+1)=α+1
53
examples
54
Non stationary Poisson Process
55
• For the arrival function in the table generate the 1st two arrival times
t(mins) mean time b/n Arrival rate
arrival (mins) A(t)
0 15 1/15
60 12 1/12
120 17 1/17
180 5 1/5
240 8 1/8
300 10 1/10
Given the random no’s are: 0.2130, 0.8830, 0.5530, 0.0240, 0.0001, 0.1443
56
Gamma Distribution
57
Special properties
• They are variate generation techniques that are based on features of
particular family of probability distributions , rather than general
purpose techniques like inverse transform or acceptance-rejection
technique.
• Direct transformation for the normal and lognormal distributions
• Convolution method
• Erlang distribution
58
Direct transformation for the normal and
lognormal distributions
• The standard normal cdf is given by
ɸ (x) = −∞
𝑥 1
√2𝜋
𝑒
𝑡2
2 𝑑𝑡 , −∞ < 𝑥 < ∞
59
Convolution method
• The probability distribution of a sum of two or more independent
random variable is called convolution of distribution of the original
variable
• The convolution method refers to adding together two or more
random variables to obtain a new random variable with a desired
distribution
60
Erlang distribution
61
End of unit 3
Thank you 
62

More Related Content

What's hot

Simulation & Modeling - Smilulation Queuing System
Simulation & Modeling - Smilulation Queuing SystemSimulation & Modeling - Smilulation Queuing System
Simulation & Modeling - Smilulation Queuing System
Maruf Rion
 
System modeling and simulation full notes by sushma shetty (www.vtulife.com)
System modeling and simulation full notes by sushma shetty (www.vtulife.com)System modeling and simulation full notes by sushma shetty (www.vtulife.com)
System modeling and simulation full notes by sushma shetty (www.vtulife.com)
Vivek Maurya
 
Unit 6 input modeling
Unit 6 input modeling Unit 6 input modeling
Unit 6 input modeling
raksharao
 
Random Number Generation
Random Number GenerationRandom Number Generation
Random Number Generation
Raj Bhatt
 
Simulation of Queueing Systems(Single-Channel Queue).
Simulation of Queueing Systems(Single-Channel Queue).Simulation of Queueing Systems(Single-Channel Queue).
Simulation of Queueing Systems(Single-Channel Queue).
Badrul Alam
 
Automata
AutomataAutomata
Automata
Gaditek
 
What is pseudo random number
What is pseudo random numberWhat is pseudo random number
What is pseudo random number
Akshay Tikekar
 
Output analysis for simulation models / Elimination of initial Bias
Output analysis for simulation models / Elimination of initial BiasOutput analysis for simulation models / Elimination of initial Bias
Output analysis for simulation models / Elimination of initial Bias
Tilakpoudel2
 
Probability basics and bayes' theorem
Probability basics and bayes' theoremProbability basics and bayes' theorem
Probability basics and bayes' theorem
Balaji P
 
Genetic Algorithms Made Easy
Genetic Algorithms Made EasyGenetic Algorithms Made Easy
Genetic Algorithms Made Easy
Prakash Pimpale
 
Monte Carlo Simulation
Monte Carlo SimulationMonte Carlo Simulation
Monte Carlo Simulation
Deepti Singh
 
Pseudo Random Number Generators
Pseudo Random Number GeneratorsPseudo Random Number Generators
Pseudo Random Number Generators
Darshini Parikh
 
Uncertainty in AI
Uncertainty in AIUncertainty in AI
Uncertainty in AI
Amruth Veerabhadraiah
 
System simulation & modeling notes[sjbit]
System simulation & modeling notes[sjbit]System simulation & modeling notes[sjbit]
System simulation & modeling notes[sjbit]
qwerty626
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
Bharat Bhushan
 
Three Address code
Three Address code Three Address code
Three Address code
Pooja Dixit
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
Dr Shashikant Athawale
 

What's hot (20)

Simulation & Modeling - Smilulation Queuing System
Simulation & Modeling - Smilulation Queuing SystemSimulation & Modeling - Smilulation Queuing System
Simulation & Modeling - Smilulation Queuing System
 
System modeling and simulation full notes by sushma shetty (www.vtulife.com)
System modeling and simulation full notes by sushma shetty (www.vtulife.com)System modeling and simulation full notes by sushma shetty (www.vtulife.com)
System modeling and simulation full notes by sushma shetty (www.vtulife.com)
 
Unit 6 input modeling
Unit 6 input modeling Unit 6 input modeling
Unit 6 input modeling
 
Random Number Generation
Random Number GenerationRandom Number Generation
Random Number Generation
 
Simulation of Queueing Systems(Single-Channel Queue).
Simulation of Queueing Systems(Single-Channel Queue).Simulation of Queueing Systems(Single-Channel Queue).
Simulation of Queueing Systems(Single-Channel Queue).
 
Input modeling
Input modelingInput modeling
Input modeling
 
Automata
AutomataAutomata
Automata
 
What is pseudo random number
What is pseudo random numberWhat is pseudo random number
What is pseudo random number
 
Output analysis for simulation models / Elimination of initial Bias
Output analysis for simulation models / Elimination of initial BiasOutput analysis for simulation models / Elimination of initial Bias
Output analysis for simulation models / Elimination of initial Bias
 
Probability basics and bayes' theorem
Probability basics and bayes' theoremProbability basics and bayes' theorem
Probability basics and bayes' theorem
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
 
Genetic Algorithms Made Easy
Genetic Algorithms Made EasyGenetic Algorithms Made Easy
Genetic Algorithms Made Easy
 
Monte Carlo Simulation
Monte Carlo SimulationMonte Carlo Simulation
Monte Carlo Simulation
 
Pseudo Random Number Generators
Pseudo Random Number GeneratorsPseudo Random Number Generators
Pseudo Random Number Generators
 
Monte carlo
Monte carloMonte carlo
Monte carlo
 
Uncertainty in AI
Uncertainty in AIUncertainty in AI
Uncertainty in AI
 
System simulation & modeling notes[sjbit]
System simulation & modeling notes[sjbit]System simulation & modeling notes[sjbit]
System simulation & modeling notes[sjbit]
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
 
Three Address code
Three Address code Three Address code
Three Address code
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 

Similar to Unit 3 random number generation, random-variate generation

MT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number GenerationMT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number Generation
Kannappan Subramaniam
 
Pseudo Random Number
Pseudo Random NumberPseudo Random Number
Pseudo Random Number
Hemant Chetwani
 
Testing Numbers for Randomness Chi Square test
Testing Numbers for Randomness Chi Square testTesting Numbers for Randomness Chi Square test
Testing Numbers for Randomness Chi Square test
RachitSharma6516
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3
Yasser Ahmed
 
Gradient descent method
Gradient descent methodGradient descent method
Gradient descent method
Sanghyuk Chun
 
myppt for health issues at IITB. Don't come to IITB
myppt for health issues at IITB. Don't come to IITBmyppt for health issues at IITB. Don't come to IITB
myppt for health issues at IITB. Don't come to IITB
dhvaniliitb
 
604_multiplee.ppt
604_multiplee.ppt604_multiplee.ppt
604_multiplee.ppt
Rufesh
 
A brief introduction to mutual information and its application
A brief introduction to mutual information and its applicationA brief introduction to mutual information and its application
A brief introduction to mutual information and its application
Hyun-hwan Jeong
 
Shor’s algorithm the ppt
Shor’s algorithm the pptShor’s algorithm the ppt
Shor’s algorithm the ppt
Mrinal Mondal
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
nourhandardeer3
 
Statr session 23 and 24
Statr session 23 and 24Statr session 23 and 24
Statr session 23 and 24
Ruru Chowdhury
 
ch09-Simulation.ppt
ch09-Simulation.pptch09-Simulation.ppt
ch09-Simulation.ppt
LuckySaigon1
 
Counting (Using Computer)
Counting (Using Computer)Counting (Using Computer)
Counting (Using Computer)
roshmat
 
Random Number Generator.pdf
Random Number Generator.pdfRandom Number Generator.pdf
Random Number Generator.pdf
Dedy PrasTyo
 
Chi square
Chi squareChi square
Chapter 1 Errors and Approximations.ppt
Chapter 1 Errors  and Approximations.pptChapter 1 Errors  and Approximations.ppt
Chapter 1 Errors and Approximations.ppt
Eyob Adugnaw
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
Muhammad Hammad Waseem
 
Chapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhd
Chapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdChapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhd
Chapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhd
beshahashenafe20
 
Lecture 2 ns
Lecture 2 nsLecture 2 ns
Lecture 2 ns
Rabiul Sarker
 

Similar to Unit 3 random number generation, random-variate generation (20)

MT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number GenerationMT6702 Unit 2 Random Number Generation
MT6702 Unit 2 Random Number Generation
 
Ppt
PptPpt
Ppt
 
Pseudo Random Number
Pseudo Random NumberPseudo Random Number
Pseudo Random Number
 
Testing Numbers for Randomness Chi Square test
Testing Numbers for Randomness Chi Square testTesting Numbers for Randomness Chi Square test
Testing Numbers for Randomness Chi Square test
 
Applied numerical methods lec3
Applied numerical methods lec3Applied numerical methods lec3
Applied numerical methods lec3
 
Gradient descent method
Gradient descent methodGradient descent method
Gradient descent method
 
myppt for health issues at IITB. Don't come to IITB
myppt for health issues at IITB. Don't come to IITBmyppt for health issues at IITB. Don't come to IITB
myppt for health issues at IITB. Don't come to IITB
 
604_multiplee.ppt
604_multiplee.ppt604_multiplee.ppt
604_multiplee.ppt
 
A brief introduction to mutual information and its application
A brief introduction to mutual information and its applicationA brief introduction to mutual information and its application
A brief introduction to mutual information and its application
 
Shor’s algorithm the ppt
Shor’s algorithm the pptShor’s algorithm the ppt
Shor’s algorithm the ppt
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
 
Statr session 23 and 24
Statr session 23 and 24Statr session 23 and 24
Statr session 23 and 24
 
ch09-Simulation.ppt
ch09-Simulation.pptch09-Simulation.ppt
ch09-Simulation.ppt
 
Counting (Using Computer)
Counting (Using Computer)Counting (Using Computer)
Counting (Using Computer)
 
Random Number Generator.pdf
Random Number Generator.pdfRandom Number Generator.pdf
Random Number Generator.pdf
 
Chi square
Chi squareChi square
Chi square
 
Chapter 1 Errors and Approximations.ppt
Chapter 1 Errors  and Approximations.pptChapter 1 Errors  and Approximations.ppt
Chapter 1 Errors and Approximations.ppt
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
 
Chapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhd
Chapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdChapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhd
Chapter Seven - .pptbhhhdfhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhd
 
Lecture 2 ns
Lecture 2 nsLecture 2 ns
Lecture 2 ns
 

More from raksharao

Unit 1-logic
Unit 1-logicUnit 1-logic
Unit 1-logic
raksharao
 
Unit 1 rules of inference
Unit 1  rules of inferenceUnit 1  rules of inference
Unit 1 rules of inference
raksharao
 
Unit 1 quantifiers
Unit 1  quantifiersUnit 1  quantifiers
Unit 1 quantifiers
raksharao
 
Unit 1 introduction to proofs
Unit 1  introduction to proofsUnit 1  introduction to proofs
Unit 1 introduction to proofs
raksharao
 
Unit 7 verification &amp; validation
Unit 7 verification &amp; validationUnit 7 verification &amp; validation
Unit 7 verification &amp; validation
raksharao
 
Unit 6 input modeling problems
Unit 6 input modeling problemsUnit 6 input modeling problems
Unit 6 input modeling problems
raksharao
 
Unit 5 general principles, simulation software
Unit 5 general principles, simulation softwareUnit 5 general principles, simulation software
Unit 5 general principles, simulation software
raksharao
 
Unit 5 general principles, simulation software problems
Unit 5  general principles, simulation software problemsUnit 5  general principles, simulation software problems
Unit 5 general principles, simulation software problems
raksharao
 
Unit 4 queuing models
Unit 4 queuing modelsUnit 4 queuing models
Unit 4 queuing models
raksharao
 
Unit 4 queuing models problems
Unit 4 queuing models problemsUnit 4 queuing models problems
Unit 4 queuing models problems
raksharao
 
Unit 1 introduction contd
Unit 1 introduction contdUnit 1 introduction contd
Unit 1 introduction contd
raksharao
 
Unit 1 introduction
Unit 1 introductionUnit 1 introduction
Unit 1 introduction
raksharao
 
Module1 part2
Module1 part2Module1 part2
Module1 part2
raksharao
 
Module1 Mobile Computing Architecture
Module1 Mobile Computing ArchitectureModule1 Mobile Computing Architecture
Module1 Mobile Computing Architecture
raksharao
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
raksharao
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
raksharao
 
Chap3 multi threaded programming
Chap3 multi threaded programmingChap3 multi threaded programming
Chap3 multi threaded programming
raksharao
 
Java-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handlingJava-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handling
raksharao
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
raksharao
 
FIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer programFIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer program
raksharao
 

More from raksharao (20)

Unit 1-logic
Unit 1-logicUnit 1-logic
Unit 1-logic
 
Unit 1 rules of inference
Unit 1  rules of inferenceUnit 1  rules of inference
Unit 1 rules of inference
 
Unit 1 quantifiers
Unit 1  quantifiersUnit 1  quantifiers
Unit 1 quantifiers
 
Unit 1 introduction to proofs
Unit 1  introduction to proofsUnit 1  introduction to proofs
Unit 1 introduction to proofs
 
Unit 7 verification &amp; validation
Unit 7 verification &amp; validationUnit 7 verification &amp; validation
Unit 7 verification &amp; validation
 
Unit 6 input modeling problems
Unit 6 input modeling problemsUnit 6 input modeling problems
Unit 6 input modeling problems
 
Unit 5 general principles, simulation software
Unit 5 general principles, simulation softwareUnit 5 general principles, simulation software
Unit 5 general principles, simulation software
 
Unit 5 general principles, simulation software problems
Unit 5  general principles, simulation software problemsUnit 5  general principles, simulation software problems
Unit 5 general principles, simulation software problems
 
Unit 4 queuing models
Unit 4 queuing modelsUnit 4 queuing models
Unit 4 queuing models
 
Unit 4 queuing models problems
Unit 4 queuing models problemsUnit 4 queuing models problems
Unit 4 queuing models problems
 
Unit 1 introduction contd
Unit 1 introduction contdUnit 1 introduction contd
Unit 1 introduction contd
 
Unit 1 introduction
Unit 1 introductionUnit 1 introduction
Unit 1 introduction
 
Module1 part2
Module1 part2Module1 part2
Module1 part2
 
Module1 Mobile Computing Architecture
Module1 Mobile Computing ArchitectureModule1 Mobile Computing Architecture
Module1 Mobile Computing Architecture
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
 
Chap3 multi threaded programming
Chap3 multi threaded programmingChap3 multi threaded programming
Chap3 multi threaded programming
 
Java-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handlingJava-Unit 3- Chap2 exception handling
Java-Unit 3- Chap2 exception handling
 
FIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer LanguagesFIT-Unit3 chapter2- Computer Languages
FIT-Unit3 chapter2- Computer Languages
 
FIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer programFIT-Unit3 chapter 1 -computer program
FIT-Unit3 chapter 1 -computer program
 

Recently uploaded

digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
benykoy2024
 

Recently uploaded (20)

digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
 

Unit 3 random number generation, random-variate generation

  • 2. contents • Random number generation • Properties of random numbers • Generation of pseudo-random numbers • Techniques for generating random numbers • Tests for Random Numbers • Random-Variate Generation: • Inverse transform technique • Acceptance-Rejection technique • Special properties 2
  • 4. Properties of random numbers • the main properties of random numbers are • Uniformity • Independence • Maximum density • Maximum period • Maximum density means that the gaps between random numbers should not be large, can be achieved by having maximum period. • Maximum period refers the length of the sequence of random numbers which are going to repeat after a certain random numbers. 4
  • 5. • Each random number Ri must be an independent sample drawn from a continuous uniform distribution between zero and 1 • The pdf of the given by • f(x)= 1 , 0 ≤ 𝑥 ≤ 1 0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 • The expected value of each is given by • E( R) = 0 1 𝑥 𝑑𝑥 = 1 2 5
  • 6. • The variance is given by • V( R) = 0 1 𝑥2 − [𝐸 𝑅 ]2 = 1 12 • The following figure shows the pdf for random numbers 6
  • 7. Generation of pseudo Random Numbers • Pseudo means false , here it implies generating random numbers by known method to remove the potential for true randomness. • If the method is known then set of random numbers can be repeated. • Which means that numbers are not random • The main goal of random generation technique is to produce a sequence of numbers between 0 and 1 that simulates or imitates the ideal properties of uniform distribution and independence • Random numbers are generated by digital computer as part of simulation, there are numerous ways to generate these values 7
  • 8. • The following are few important considerations • The method should be fast, simulation process requires millions of random numbers hence it has to be fast • The method has to be portable to different computer • The method should have sufficiently long cycle, means there should be long gap between the random numbers once generated getting repeated. • The random numbers should be repeatable • The generated random numbers should closely approximate the ideal statistical properties of uniformity and independence 8
  • 9. Errors or departures of pseudo random numbers • The generated random numbers might not be uniformly distributed. • Generated numbers might be discrete value instead of continuous value. • The mean of generated random numbers might be too high or too low • The variance of generated numbers might be too high or too low • There might be dependence • Authentication between numbers • Numbers successively higher or lower than adjacent numbers • Several numbers above the mean followed by several numbers below the mean. 9
  • 10. Techniques for generating random numbers • Linear congruential method • Combined linear congruential generators • Random number streams 10
  • 11. Linear congruential method • Proposed by Lehmer, produces a sequences of integer numbers X1,X2 , … between zero and m-1 by following the recursive relationship: • X i+1= (aXi+c) mod m, i=0,1,2,3… • The initial value i.e. x0 is called seed • a is called multiplier • c is called the increment • m is called the modulus 11
  • 12. • If c ≠ 𝟎 then form is called mixed congruential method • When c=0, the form is called multiplicative congruential method • The selection of the values for a, c, m and X0 affects the statistical properties and the cycle length. • Random numbers Ri between 0 and 1 can be generated by setting • Ri = 𝑿 𝒊 𝒎 , i=1,2,… 12
  • 14. Combined linear congruential generators • Combine two or more multiplicative congruential generators in such a way that the combined generator has good statistical properties and longer period. • The following result from L’ Ecuyer suggest how this can be done: 14
  • 16. Combined linear congruential generators • The maximum possible period is given by 16
  • 18. Tests for random numbers • Number of tests are performed to check the uniformity and independence of random numbers • Two types of tests are • Frequency test : compares the distribution of the set of numbers generated to a uniform distribution. Few are: • Kolmogorov-Smirnov Test • Chi-square Test • Autocorrelation test: tests the correlation between the two numbers and compares the sample correlation to the desired correlation, zero • Runs test • Gap test • Pokers test 18
  • 19. Kolmogorov- Smirnov Test –for uniformity (Procedure) 1. Formulate the hypothesis H0:Ri ~U[0,1] H1:Ri ~U[0,1] 2. Rank the data from smallest to largest R(1)≤R(2) ≤R(3)… 3. Calculate the values of D+ and D- 19
  • 20. 4. Find D=max(D+,D-) 5. Find the critical value Dα from the K-S table 6. If D> Dα then reject the hypothesis H0 else If D < Dα then accept the hypothesis H0 20
  • 23. Chi-square Test –for uniformity (Procedure) 1. Formulate the hypothesis H0:Ri ~U[0,1] H1:Ri ~U[0,1] 2. Divide the data into different class intervals of equal intervals 3. Find out how many random numbers lie in each interval and hence find Oi (observed frequency) & expected frequency Ei using the formula Ei = 𝑁 𝑛 where N is the total no of observation n is the no of class interval L=n-1 is known as degree of freedom 23
  • 27. Tests for autocorrelation (Test for independence of random numbers) • The test for autocorrelation are concerned with the dependence between numbers in a sequence. • The autocorrelation between every m numbers starting with ith number i.e. Ri,Ri+m,Ri+2m, … , Ri+(m+1)m is ρ im • The value M is the largest integer such that i+(m+1)≤N where N is the total number of values in the sequence • A non-zero autocorrelation implies a lack of independence H0: ρ im = 0 H1: ρ im ≠ 0 27
  • 28. • For large value of M, the distribution of the estimator of ρ im is denoted as ρ im • the test statistics is as follows • Which is distributed normally with a mean of 0 and variance of 28
  • 29. • And standard deviation of 29
  • 30. • After computing Z0, do not reject the null hypothesis of independence if • −𝑧 𝛼 2 ≤ Z0 ≤ 𝑧 𝛼 2 where is the level of significance and • 𝑧 𝛼 2 is obtained from a following table A-3 30
  • 31. Runs test • Definition: The runs test is defined as sequence of similar preceded and followed by different events • Eg. Suppose tossing a coin 10 times results in the following sequence • H H T T T H T H T T • Here are 6 runs, first one of length 2, 2nd length of 3, 3rd ,4th ,5th of length 1 and 6th of length 2 • Two points to be considered while performing runs test • No of runs • Length of each run 31
  • 32. Runs up and runs down 32 • A run is said to be up if its followed by a bigger number and down if the number is followed by a smaller number • Since last number is not followed by any number, the maximum number of runs is n-1 where n is the number of observation • Procedure of the runs up and runs down is as follows • Step 1 : H0: Ri is independent H1: Ri is not independent
  • 33. • Step 2: find runs up and runs down by assigning the + sign to every random number that is followed by bigger number and – sign to a number that is followed by a smaller number • Step 3: find the total number of runs (a) • Step 4: calculate 𝑍 = 𝑎−𝜇 𝑎 𝜎 𝑎 where 𝜇 𝑎=(2N-1)/3 and 𝜎 𝑎=sqrt((16N-29)/90) where N is total number of observation • Step 5: find the critical value 𝑧 𝛼 2 from the normal table • Step 6: reject H0 if |Z|≥ 𝑧 𝛼 2 otherwise accept H0 33
  • 36. Inverse-transform technique • It can be used to sample from the exponential , uniform, Weibull and triangular distributions and from empirical distributions. • Underlying principle for sampling from a wide variety of discrete distributions. • Most straightforward but not always efficient technique. Few are • Exponential distribution • Uniform distribution • Weibull distribution • Triangular distribution • Empirical discrete distribution • Discrete uniform distribution • Geometric distribution 36
  • 37. Exponential distribution • Probability density function (pdf) is given by • 𝑓 𝑥 = λ𝑒−λ𝑥 , 𝑥 ≥ 0 0, 𝑥 < 0 • The cumulative distribution function (cdf) is given by • F(x)= −∞ 𝑥 𝑓 𝑡 𝑑𝑡 = 1 − 𝑒−λ𝑥, 𝑥 ≥ 0 0 , 𝑥 < 0 37
  • 38. Procedure for inverse transform technique 38
  • 39. 39
  • 40. 40
  • 42. Uniform distribution • Consider a random variable X i.e. uniformly distributed on the interval [a,b]. • Step 1 : the cdf is given by F(x) = 0, 𝑥 < 𝑎 𝑥−𝑎 𝑏−𝑎 , 𝑎 ≤ 𝑥 ≤ 𝑏 1, 𝑥 > 𝑏 • Step 2: Set F(x)= 𝑥−𝑎 𝑏−𝑎 = R • Step 3: on solving we get , X=a+(b-a)R which is the equation for random variate generation using uniform distribution 42
  • 43. Weibull distribution • The pdf is given 43
  • 45. 45
  • 48. 48
  • 50. 50
  • 51. 51
  • 52. Acceptance – rejection technique • Devising a method for generating random numbers ‘X’ uniformly distributed between ¼ and 1 follows three steps 1. Generate a random number R 2. a) If R ≥ ¼ accept X=R the goto step 3 2. b) if R < ¼ reject R and return to step 1 3. If another uniform random variate on [1/4,1] is needed, repeat the procedure beginning at step 1 , if not stop. 52
  • 53. Poisson distribution • Step 1 : Set n=0, P=1 • Step 2 : generate a random number Rn+1 , replace P by P.Rn+1 • Step 3: If P < 𝑒−𝛼 then accept N=n, otherwise reject the current n, increase n by one and return to step 2 • With N=n poison of average number is given by E(N+1)=α+1 53
  • 56. • For the arrival function in the table generate the 1st two arrival times t(mins) mean time b/n Arrival rate arrival (mins) A(t) 0 15 1/15 60 12 1/12 120 17 1/17 180 5 1/5 240 8 1/8 300 10 1/10 Given the random no’s are: 0.2130, 0.8830, 0.5530, 0.0240, 0.0001, 0.1443 56
  • 58. Special properties • They are variate generation techniques that are based on features of particular family of probability distributions , rather than general purpose techniques like inverse transform or acceptance-rejection technique. • Direct transformation for the normal and lognormal distributions • Convolution method • Erlang distribution 58
  • 59. Direct transformation for the normal and lognormal distributions • The standard normal cdf is given by ɸ (x) = −∞ 𝑥 1 √2𝜋 𝑒 𝑡2 2 𝑑𝑡 , −∞ < 𝑥 < ∞ 59
  • 60. Convolution method • The probability distribution of a sum of two or more independent random variable is called convolution of distribution of the original variable • The convolution method refers to adding together two or more random variables to obtain a new random variable with a desired distribution 60
  • 62. End of unit 3 Thank you  62