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

  1. Divide the interval [0, 1] into subintervals as shown in Figure,
    1. ๐ด0= [0, ๐‘0)
    2. ๐ด1= [๐‘0, ๐‘0+๐‘1)
    3. ๐ด2= [๐‘0+๐‘1, ๐‘0+๐‘1+๐‘2)
    4. etc
  2. subinterval ๐ดiwill have length ๐‘i; there may be a finite or infinite number of them,ย according to possible values ofย ๐—
  3. obtain a Standard Uniform random variable ๐” from a random number generator or a table of random numbers
  4. ifย ๐” belongs toย ๐ดi, letย ๐—=xi

from the Uniform Distribution, it follows that:

๐{๐—ย = ๐‘ฅi} =ย ๐{๐”ย โˆˆ ๐ดi} =ย ๐‘i

Hence, the generated variable ๐—ย has the desired distribution