[SciPy-user] Generate random samples from a non-standard distribution

Robert Kern robert.kern@gmail....
Fri Oct 19 02:27:55 CDT 2007


Manu Hack wrote:
> Hi,
> 
> I've been goolging around but not sure how to generate random samples
> given the density function of a random variable.  I was looking around
> something like scipy.stats.rv_continuous but couldn't find anything
> useful.

No, we don't have any general samplers like that. It is difficult to construct
worthwhile general samplers. Most of them involve knowing at least a little bit
of information about the distribution. I like this group's approach:

  http://statmath.wu-wien.ac.at/projects/arvag/index.html

If you would like to implement some of their strategies for scipy (from the
original literature, not their GPLed code), I'd be more than happy to help you
with such an endeavor.

> Also, if one wants to do Markov Chain Monte Carlo, is scipy possible
> and if not, what should be a workaround (if still want to do in
> Python).  I heard something like openbugs but seems that debian
> doesn't have a package.

http://code.google.com/p/pymc/

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco


More information about the SciPy-user mailing list