general method of generating discrete random variables of a particularย discrete distribution
consider an arbitrary discrete random variable ๐ย that takes values ๐ฅ0, ๐ฅ1, โฆ withย probabilities ๐0, ๐1, โฆ
- ๐i = ๐{๐ย = ๐ฅi}
- โ๐i = 1
simulatingย ๐ can be done with the following steps
- Divide the interval [0, 1] into subintervals as shown in Figure,
- ๐ด0= [0, ๐0)
- ๐ด1= [๐0, ๐0+๐1)
- ๐ด2= [๐0+๐1, ๐0+๐1+๐2)
- etc
- subinterval ๐ดiwill have length ๐i; there may be a finite or infinite number of them,ย according to possible values ofย ๐
- obtain a Standard Uniform random variable ๐ from a random number generator or a table of random numbers
- ifย ๐ belongs toย ๐ดi, letย ๐=xi
from the Uniform Distribution, it follows that:
๐{๐ย = ๐ฅi} =ย ๐{๐ย โ ๐ดi} =ย ๐i
Hence, the generated variable ๐ย has the desired distribution