[SciPy-dev] [SciPy-user] random number sampling performance in newcore

Travis Oliphant oliphant at ee.byu.edu
Tue Nov 8 17:18:49 CST 2005

Chris Fonnesbeck wrote:

>I was surprised to find that the random number sampler in newcore is
>significantly slower than RandomArray in Numeric (at least for
>binomial sampling). A quick comparison showed the
>scipy.basic.random.binomial sampler to be over 8 times slower than
>RandomArray.binomial. I was surprised, since the newcore stuff is
>Pyrex-based (isnt it?). Am I the only one observing such differences,
>or am I using the wrong method? If not, is the performance expected to
>improve significantly.
I see about 4x slower as well for this particular distribution.   I'm 
not sure if this is due to the Pyrex interface (hand-wrapped extension 
modules can be faster), or to the use of a different random-number 

But, I'm getting that the random number generator itself is about 5x 
faster.  So, perhaps there is something going on with the binomial 
generator or interface.

 >>> t1 = Timer('a = RandomArray.random((500,))','import RandomArray')
 >>> t1.timeit(100)
 >>> t2 = Timer('a = scipy.random.random((500,))','import scipy')
 >>> t2.timeit(100)

More information about the Scipy-dev mailing list