Non-uniform Random Numbers - Finite Discrete Distributions

Finite Discrete Distributions

For a discrete probability distribution with a finite number n of indices at which the probability mass function f takes non-zero values, the basic sampling algorithm is straightforward. The interval [0, 1) is divided in n intervals [0, f(1)), [f(1), f(1) + f(2)), ... The width of interval i equals the probability f(i). One draws a uniformly distributed pseudo-random number X, and searches for the index i of the corresponding interval. The so determined i will have the distribution f(i).

Formalizing this idea becomes easier by using the cumulative distribution function

It is convenient to set F(0) = 0. The n intervals are then simply [F(0), F(1)), [F(1), F(2)), ..., [F(n − 1), F(n)). The main computational task is then to determine i for which F(i − 1) ≤ X < F(i).

This can be done by different algorithms:

  • Linear search, computational time linear in n.
  • Binary search, computational time goes with log n.
  • Indexed search, also called the cutpoint method.
  • Alias method, computational time is constant, using some pre-computed tables.
  • There are other methods that cost constant time.

Read more about this topic:  Non-uniform Random Numbers

Famous quotes containing the words finite and/or discrete:

    Are not all finite beings better pleased with motions relative than absolute?
    Henry David Thoreau (1817–1862)

    We have good reason to believe that memories of early childhood do not persist in consciousness because of the absence or fragmentary character of language covering this period. Words serve as fixatives for mental images. . . . Even at the end of the second year of life when word tags exist for a number of objects in the child’s life, these words are discrete and do not yet bind together the parts of an experience or organize them in a way that can produce a coherent memory.
    Selma H. Fraiberg (20th century)