Simulation Lecture 8
[Pages:36]2WB05 Simulation Lecture 8: Generating random variables
Marko Boon
January 7, 2013
Outline 2/36 1. How do we generate random variables? 2. Fitting distributions
Department of Mathematics and Computer Science
Generating random variables 3/36
How do we generate random variables?
? Sampling from continuous distributions ? Sampling from discrete distributions
Department of Mathematics and Computer Science
Continuous distributions 4/36
Inverse Transform Method
Let the random variable X have a continuous and increasing distribution function F. Denote the inverse of F by F-1. Then X can be generated as follows:
? Generate U from U (0, 1); ? Return X = F-1(U ). If F is not continuous or increasing, then we have to use the generalized inverse function
F-1(u) = min{x : F(x) u}.
Department of Mathematics and Computer Science
Continuous distributions 5/36
Examples
? X = a + (b - a)U is uniform on (a, b); ? X = - ln(U )/ is exponential with parameter ; ? X = (- ln(U ))1/a/ is Weibull, parameters a and . Unfortunately, for many distribution functions we do not have an easy-to-use (closed-form) expression for the inverse of F.
Department of Mathematics and Computer Science
Continuous distributions 6/36
Composition method
This method applies when the distribution function F can be expressed as a mixture of other distribution functions F1, F2, . . .,
F(x) = pi Fi (x),
i =1
where
pi 0,
pi = 1
i =1
The method is useful if it is easier to sample from the Fi 's than from F.
? First generate an index I such that P(I = i) = pi , i = 1, 2, . . .
? Generate a random variable X with distribution function FI .
Department of Mathematics and Computer Science
Continuous distributions 7/36
Examples
? Hyper-exponential distribution:
F(x) = p1 F1(x) + p2 F2(x) + ? ? ? + pk Fk(x), x 0,
where Fi (x) is the exponential distribution with parameter ?i , i = 1, . . . , k. ? Double-exponential (or Laplace) distribution:
where f denotes the density of F.
1 2
ex
,
x < 0;
f (x) =
1 2
e-x
,
x 0,
Department of Mathematics and Computer Science
Continuous distributions 8/36
Convolution method
In some case X can be expressed as a sum of independent random variables Y1, . . . , Yn, so X = Y1 + Y2 + ? ? ? + Yn.
where the Yi 's can be generated more easily than X . Algorithm:
? Generate independent Y1, . . . , Yn, each with distribution function G; ? Return X = Y1 + ? ? ? + Yn.
Department of Mathematics and Computer Science
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- cs229 section python tutorial
- introduction to python harvard university
- scientific and mathematical computing using python
- the random module
- networkx network analysis with python
- simulation programming with python
- basic python programming for loops and reading files
- random number generation
- python chapter 2 if statement random class
- python 3 tutorialspoint
Related searches
- free online city building simulation games
- stock market simulation for students
- photosynthesis simulation lab
- history simulation games
- elodea simulation lab
- protein synthesis simulation lab answers
- best stock market simulation game
- protein synthesis simulation lab
- photosynthesis simulation worksheet
- protein synthesis simulation answer key
- business tycoon simulation games
- best city simulation games