Download presentation
Presentation is loading. Please wait.
1
Random number generation
Chapter 3 Random number generation
2
Topics Solving problems using random number tables
Generation of random numbers that are Discrete and uniform Non uniform and discrete Non uniform and continuous Exponential Uniform in (a,b) Normal Rejection method
3
Discrete and uniform numbers
Suppose the range is 1 to 5 Using table of uniform numbers we can generate the numbers as follows: Use numbers in the table and multiply each by 4 and add 1 and truncate (or round) The first few numbers are , , , , When you do the operations above the numbers generated numbers are 1,2,1,4,1 Generate 25 numbers and make a frequency distribution
4
Problems Assuming a normal 365 day year generate first 10 dates of the year Solution Generate month using one column Date using another Why do like this?
5
Problems The probability that a batter swings the bat is 0.7, strikes the ball is 0.6 and he is caught is Compute the number of plays that he will be out in first 10 plays Use columns 1, 2 and 3 for the three events The theoretical probability that he is out is 0.7 x 0.6 x 0.5 = 0.21 The expected number of plays he will be out in 10 balls is 0.21 x 10 = 2
6
Non uniform discrete distribution
Assume a single item inventory simulation in a retail store. Let us find the average sales in 10 days. You are given the following information regarding the demand of the item (let us say soap). Assume that reorder of 15 soaps and reorder point to be 5 soaps and lead time is 1 day Suppose that the distribution of customers asking for soap in a day is No. of customers Probability Cumulative probability
7
Non uniform discrete distribution
Suppose that the distribution of demand of soaps is No. of soaps Probability Cum Prob Assume initial stock of 12 soaps Day I S R N No. customers R Ns Soaps sold F S …..
8
How does this kind of generation work?
x P(x) Cum P(x) and Plot of cdf: o o
9
How does this kind of generation work?
1 is generated if the uniform random number is between 0.2 to 0.45 If 100 numbers are generated then number of times 1 is generated is ( ) x 100 = 25 There is a match between theoretical frequency and the no of numbers generated by the generator
10
Non uniform continuous distribution
x P(x) CP For the random number in the table the interval is chosen Use the cdf (line) in this interval and find the number corresponding to
11
Non uniform continuous distribution
x P(x) CP o o
12
Non uniform continuous distribution
x P(x) CP The cdf line in the interval is join of (20, 0.08) and (40, 0.24) For the cumulative probability the random number generated is {[( )/ ( )]*(40-20) }+20
13
Exponential Many arrivals to a queue are Poisson or pure random
The inter arrivals are exponential Service times are often exponential T be mean inter arrival time be mean inter arrival rate Then T=1/ Example: Mean inter arrival time be 20 sec Then mean arrival rate is 1 in 20 or 1/20 arrivals in a sec
14
Exponential PDF is f(x)=e- x , x≥0 CDF is y=F(x)=1- e- x , x≥0
x=- log(1-y)/ , where y is uniform in (0,1) x=- log(y)/ Inverse transformation method
15
Principle of inverse transformation
F(x) y x x
16
Algorithm for exponential random number generation
Algorithm exp(lambda) Global u, x x= –ln(y)/lambda Return x End algorithm exp
17
Normal (Gaussian) PDF is not integrable No cdf function Method 1
Generate k unit uniform numbers Find their sum n=(sum – k/2 )/sqrt(k/12) is standard normal If random variates that are normal with mean a and sd b are to be generated then it is n*b+a
18
Normal (Gaussian) Convenient and quick formula for standard normal generation Generate 12 unit uniform numbers Find their sum n=(sum – 6 ) is standard normal If random variates that are normal with mean a and sd b are to be generated then it is n*b+a
19
Normal (Gaussian) Method 2 n=((-2lnx)1/2 ) cos(2y) is standard normal
Here x, y are unit uniform numbers n=((-2lnx)1/2 ) sin(2y) is standard normal If random variates that are normal with mean a and sd b are to be generated then it is n*b+a
20
Rejection method For obtaining samples from non uniform distribution
Basically generate uniform random numbers and accept those that meet some criteria The criteria is designed so that generated numbers are from the given distribution
21
Rejection method f(x) q q c A p p B x
Range of p is (A,B) and that of q is (0,c)
22
Lab problems Generate exponential, uniform in (a,b) and normal variates and plot frequencies Generate empirical discrete and continuous distribution random variates and plot frequencies Simulate the soap problem
23
Summary and references
Solving problems using random number tables – Chapter 6, G. Gordon Generation of random numbers that are Discrete and uniform - G. Gordon, Chapter 6; N.Deo, Chapter 3 Non uniform and discrete - G. Gordon, Chapter 6; N.Deo, Chapter 3 Non uniform and continuous - G. Gordon, Chapter 6; N.Deo, Chapter 3 Exponential - G. Gordon, Chapter 7; N.Deo, Chapter 3 Uniform in (a,b) - G. Gordon, Chapter 7; N.Deo, Chapter 3 Normal - G. Gordon, Chapter 7; N.Deo, Chapter 3 Rejection method - N.Deo, Chapter 3
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.