Re: problem with RandomInteger

*To*: mathgroup at smc.vnet.net*Subject*: [mg112203] Re: problem with RandomInteger*From*: Mark Adler <madler at alumni.caltech.edu>*Date*: Sat, 4 Sep 2010 04:02:13 -0400 (EDT)*References*: <i5qhhg$pkm$1@smc.vnet.net>

Interesting and alarming. The behavior is the same with both Module and Block. In either case if any one of the local variables is removed from the local list, the problem goes away. All three need to be there. So it does seem to be related somehow to the use of Module, Block, and local (dynamic or lexical) variables. There is no problem with a non Module/Block variant of the function, such as Boole[RandomInteger[{1,3}]==RandomInteger[{1,3}]]. When trying to look at what was going on by putting Print's inside, the problem went away! (Heisenberg's Uncertainty Principle.) Guessing from that that it was a timing thing, I found that if I put Pause[$TimeUnit]; anywhere in the function, the problem goes away. Some sort of race condition perhaps? However when I use ParallelTable (which launches another kernel), the problem goes away. The behavior changes abruptly at length 250. Up to length 249, all is normal. At length 250, the table is always a few zeros and ones followed by all ones, or the table is simply all ones. Beats me what's going on. Mark