[SciPy-user] Making faster statistical distributions

Robert Kern rkern at ucsd.edu
Thu Jan 29 13:28:47 CST 2004

On Thu, Jan 29, 2004 at 03:53:10PM -0500, Christopher Fonnesbeck wrote:


> Well, the binomial and normal distributions, for sure, off the top of 
> my head. Using the scipy distributions slows my MCMC code down 
> significantly (they were the bottleneck, according to the profiling 
> module). Using Fortran via f2py sped things up a lot. I'm not talking 
> about the generation of random deviates, necessarily, but rather the 
> pdf's, which are used for calculating likelihoods.

I'm willing to bet that the speed is lost by the generality of the
framework. There's a lot of argument manipulation and not a lot of
actual computation. It might be useful to add a fastdists module that
computes pdfs and cdfs in a more specific (but fast) way for the more
common distributions. And log-pdfs, too, please! In fact, log-pdfs
first since in many instances like MCMC, they're much more suitable.

One could then override pdf() and cdf() (not _pdf() and _cdf()) in the
specific classes. But that's a design that appears to have been decided

> C.

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

More information about the SciPy-user mailing list