JuliaStats/Distributions.jl — pull request #76 by simonbyrne (2013-07-09 14:13:54+00:00)
Title: Huffman coding tree for sampling discrete vars

This adds a Huffman coding tree for simulating high-dimensional discrete variables (which is theoretically the optimal way to do it) in an attempt to fix #70. At the moment it is still a bit slower than the current alias table implementation in simulating random variables (which is why I haven't "plugged it in" yet), but is much, much quicker in setting up.

It also has some other desirable features:
* it has a larger state-space: the minimum "granularity" is 1/float64(typemax(Uint64)) = 5.4-20.
* it can handle non-base2 divisions via rejection sampling.