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:
“We know then the existence and nature of the finite, because we also are finite and have extension. We know the existence of the infinite and are ignorant of its nature, because it has extension like us, but not limits like us. But we know neither the existence nor the nature of God, because he has neither extension nor limits.”
—Blaise Pascal (16231662)
“The mastery of ones phonemes may be compared to the violinists mastery of fingering. The violin string lends itself to a continuous gradation of tones, but the musician learns the discrete intervals at which to stop the string in order to play the conventional notes. We sound our phonemes like poor violinists, approximating each time to a fancied norm, and we receive our neighbors renderings indulgently, mentally rectifying the more glaring inaccuracies.”
—W.V. Quine (b. 1908)