[Numpy-discussion] python's random.random() faster than numpy.random.rand() ???

Mark P. Miller mpmusu at cc.usu.edu
Fri Jan 26 12:17:58 EST 2007


Greetings:

I've recently been working with numpy's random number generators and 
noticed that python's core random number generator is faster than 
numpy's for the uniform distribution.

In other words,

for a in range(1000000):
     b = random.random()    #core python code

is substantially faster than

for a in range(1000000):
     b = numpy.random.rand()    #numpy code


For other distributions that I've worked with, numpy's random number 
generators are much faster than the core python generators.

Any thoughts?  Just wanted to mention it to you.  Or should I be using 
some other approach to call numpy's uniform generator?

-Mark


-- 
Dr. Mark P. Miller
Department of Biology
5305 Old Main Hill
Utah State University
Logan, UT 84322-5305 USA
 ><><><><><><><><><><><><><><><><
http://www.biology.usu.edu/people/facultyinfo.asp?username=mpmbio
http://www.marksgeneticsoftware.net



More information about the NumPy-Discussion mailing list