Pseudo-Random Number Generation

Let X be any discrete random variable with pmf f(x).

Here is the ugliest discrete distribution we could find:  Holla’s distribution ...     the pmf contains a BesselK function, it has no closed form cdf, it is non-invertible etc. So, to illustrate, let X ∼ Holla(μ, λ) with pmf f(x):

In[1]:= DiscreteRNG_3.gif

The DiscreteRNG function in mathStatica 2 takes less than ½ second to generate 1 million pseudo-random drawings from this beast:

In[2]:= DiscreteRNG_6.gif

Out[2]= DiscreteRNG_7.gif

 

Compare the EMPIRICAL distribution of data () ]with the TRUE distribution of X ():

In[3]:= DiscreteRNG_8.gif

Out[3]= DiscreteRNG_9.gif

Fig. 1: The empirical pmf (red triangles) and true pmf (blue circles)

The triangular dots denote the empirical pmf, while the round dots denote the true density. One obtains a superb fit because mathStatica's DiscreteRNG function is an exact solution.

References
Rose, C. and Smith, M. D. (1997), Random number generation for discrete variables, Mathematica in Education and Research, Springer-Verlag, 6(3), 22–26.