utilities for sampling from categorial distributions.
Stochastically generate derivations.