470,848 Members | 1,887 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

Subtle architecture-dependent bug in Numeric.RandomArray

There is a subtle bug in the RandomArray module, which is part of
the Numeric package. It causes the random number generator
RandomArray.normal() to return incorrect values when invoked on Linux
compiled with gcc on a AMD Opteron machine, that is, a system with
64-Bit CPU and ILP64 data model. The result will depend on the data model
and the aligning of the C implementation on the used architecture.
The bug seems not to be triggered on 32-bit systems.

Cause of the bug are the code lines

ranlibmodule.c:get_continuous_random, line 48:
case 0:
*out_ptr = (double) ((double (*)()) fun)();


ranlibmodule.c:standard_normal, line 125:
static PyObject *
standard_normal(PyObject *self, PyObject *args) {
return get_continuous_random(0, self, args, snorm);

where fun is a function pointer to the functions ranf() or
snorm(). However, only in the case of ranf(),
the function returns actually a double value, snorm(),
which is used to generate Gaussian random numbers, returns
a float.

The Numpy package, which is the recommended replacement
for Numeric, uses a different random number generator
(the Mersenne Twister RNG) and does not contain this code.
Kind Regards,

Johannes Nix
Apr 3 '06 #1
0 894

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by David Noble | last post: by
6 posts views Thread by carsonbj | last post: by
13 posts views Thread by rrs.matrix | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.