By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,079 Members | 880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,079 IT Pros & Developers. It's quick & easy.

Preferred Random Library

P: n/a
Is there a preferred random library?

scipy.random
random

Besides scipy's library returning ndarrays, is there any other
advantage/disadvantage?
Apr 26 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Bill Jackson <ja*****@hotmail.comwrites:
Is there a preferred random library?
Preferred for what? Maybe you want os.urandom().
Apr 26 '07 #2

P: n/a
Paul Rubin wrote the following on 04/25/2007 10:17 PM:
Bill Jackson <ja*****@hotmail.comwrites:
>Is there a preferred random library?

Preferred for what? Maybe you want os.urandom().
How about for general usage...I am just asking for a very broad
description of the advantages/disadvantages of each.

For instance, what is the scipy.random equivalent of random.jumpahead()?

Apr 26 '07 #3

P: n/a
Bill Jackson wrote:
Is there a preferred random library?

scipy.random
random

Besides scipy's library returning ndarrays, is there any other
advantage/disadvantage?
numpy.random (since that's where scipy.random comes from, I recommend always
referring to it as numpy.random) can be a bit faster since it is implemented as
entirely an extension module; parts of random are implemented in Python and
incur Python function call overhead. It's certainly faster if you need a lot of
numbers at once. numpy.random has several more non-uniform distributions
implemented.

numpy.random does not implement jumpahead(). random, naturally, does not require
a third-party package.

By and large, I'd say the distinguishing factor is whether or not you want to
use numpy in your program. If so, then use numpy.random. If not, then use random.

--
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

Apr 26 '07 #4

P: n/a
"Robert Kern" <ro*********@gmail.comwrote in message
news:ma***************************************@pyt hon.org...
numpy.random does not implement jumpahead().
Which may be removed from the random API:
http://www.python.org/dev/peps/pep-3...andard-library

Cheers,
Alan Isaac
Apr 26 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.