Sampler for discrete and continuous random distributions.