Re: [Numpydiscussion] random number facilities in numarray and main Python libs
Hi, The R project (http://www.rproject.org) provides a standalone GPL'ed Math library (buried in the src/nmath/standalone subdirectory of the R code). This includes random number generators for various distributions amongst other goodies. But I have not looked to see what approach that the actual uniform random generator uses (source comment says "A version of MarsagliaMultiCarry"). However, this library should be as least as good as and probably better than Ranlib that is currently being used I used SWIG to generate wrappers for most of the functions (except the voids). SWIG makes it very easy but I needed to create a SWIG include file because using the header alone did not work correctly. If anyone wants more information or files, let me know. Bruce Southey  Original message 
Date: Tue, 07 Sep 2004 16:35:11 0700 From: Robert Kern <rkern@ucsd.edu> Subject: Re: [Numpydiscussion] random number facilities in numarray and main Python libs To: numpydiscussion@lists.sourceforge.net
Faheem Mitha wrote: [snip]
Are the random number facilities provided by numarray.random_array superior to those provided to those provided by the random module in the Python library? They certainly seem more extensive, and I like the interface better.
If so, why not replace the random module by the equivalent functionality from numarray.random_array, and have everyone use the same random number generator? Or is this impossible for practical reasons?
numarray.random_array can generate arrays full of random numbers. Standard Python's random does not and will not until numarray is part of the standard library. Standard Python's random also uses the Mersenne Twister algorithm which is, by most accounts, superior to RANLIB's algorithm, so I for one would object to replacing it with numarray's code. :)
I do intend to implement the Mersenne Twister algorithm for SciPy's PRNG facilities (on some unspecified weekend). I will also try to code something up for numarray, too.
By the way, what is the name of the pseudorandom number generator being used? I see that the code is in Packages/RandomArray2/Src, but could not see where the name of the generator is mentioned.
<URL:http://orion.math.iastate.edu/burkardt/c_src/ranlib/ranlib_base.txt> documents the base algorithm.
Faheem.
 Robert Kern rkern@ucsd.edu
"In the fields of hell where the grass grows high Are the graves of dreams allowed to die."  Richard Harter
 This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click _______________________________________________ Numpydiscussion mailing list Numpydiscussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpydiscussion
On Tue, 7 Sep 2004, Bruce Southey wrote:
Hi,
The R project (http://www.rproject.org) provides a standalone GPL'ed Math library (buried in the src/nmath/standalone subdirectory of the R code). This includes random number generators for various distributions amongst other goodies. But I have not looked to see what approach that the actual uniform random generator uses (source comment says "A version of MarsagliaMultiCarry"). However, this library should be as least as good as and probably better than Ranlib that is currently being used
I used SWIG to generate wrappers for most of the functions (except the voids). SWIG makes it very easy but I needed to create a SWIG include file because using the header alone did not work correctly. If anyone wants more information or files, let me know.
I'm modestly familiar with R. I think its random number facilities are likely to be as good as anything out there, since it is a tool for computational resarch statistics. Actually R has something like 5 different random number generators, and you can switch from one to the other on the fly. Very cool. I hacked on the random number stuff for something I had to do once, and the code was reasonably clean (C implementation, of course). Since R is GPL'd, I assume it would be possible to use the code in Python. Faheem.
On Tue, 7 Sep 2004, Bruce Southey wrote:
Hi, The R project (http://www.rproject.org) provides a standalone GPL'ed Math library (buried in the src/nmath/standalone subdirectory of the R code). This includes random number generators for various distributions amongst other goodies. But I have not looked to see what approach that the actual uniform random generator uses (source comment says "A version of MarsagliaMultiCarry"). However, this library should be as least as good as and probably better than Ranlib that is currently being used
I used SWIG to generate wrappers for most of the functions (except the voids). SWIG makes it very easy but I needed to create a SWIG include file because using the header alone did not work correctly. If anyone wants more information or files, let me know.
Sorry for the slow response. Yes, I would be interested in seeing your work. I'd be particularly interested in learning how you interfact the random number generator in python with the one in C. Myself, I'd incline towards a more "manual" approach using the C Python API or possibly the Boost.Python C++ library. Perhaps you can make it publicly available by putting it on the web and posting the url here? Thanks. Faheem.
participants (2)

Bruce Southey

Faheem Mitha