[SciPy-dev] Monte Carlo package

Ed Schofield schofield at ftw.at
Tue Jan 24 11:35:45 CST 2006

Robert Kern wrote:

>Ed Schofield wrote:
>>Hi all,
>>The Monte Carlo package now builds and runs fine for me on MinGW.  I'd
>>now like to ask for some help with testing on other platforms.  (Are
>>there any that don't define the rand() function? ;)
>I really would prefer that it not use rand() but use numpy.random instead. What
>do you need to make this happen?
Hmmm ... do you mean rk_random() defined in
numpy/random/mtrand/randomkit.c? I guess I could link to this instead of
the system default rand(), but this is probably overkill for this
application.  I just need a single 30-bit random number per instance, to
use as a seed.  I could use the system time directly, but at the moment
I use rand() to scramble it up a little first:

    /* First seed our faster XORshift RNG. */
    /* We need to do this in a way that supports non-SVID C platforms.
     * We use rand() twice, constructing a 30-bit integer out of the
     * two results. */
    srand( (unsigned int) time( NULL ));
    seedhigh = rand();
    seedlow = rand();

    /* Construct a 30-bit random integer out of these. */
    jxr = ((seedhigh & 0x3fff) << 16) + (seedlow & 0xffff);

I fear that depending on the randomkit.h header would just add an
unnecessary build dependency.  Do you still see a need for it?

-- Ed

More information about the Scipy-dev mailing list