|
From: Nick C. <nic...@ve...> - 2004-10-19 18:33:33
|
Walter, I received the following from the colt list. The normal distribution does indeed draw two from the stream and caches one. So, I think this explains the behavior. Nick -----Original Message----- From: Adrian Kujaneck Agogino [mailto:ag...@ec...] Sent: Tuesday, October 19, 2004 2:23 PM To: Nick Collier Cc: co...@li... Subject: Re: Strange interaction between uniform and normal It looks like the uniform distribution asks the random generator for a single number for each call to "nextDouble." The normal distribution asks for two, generates two normally distributed numbers and caches one of them. If they are drawing from a common random number generator, this would explain what you are seeing. -adrian On Mon, 18 Oct 2004, Nick Collier wrote: > Sorry, if this is a repeat. It may not have sent the first time. > > Hi all, > > I've noticed a strange interaction between doing draws from the uniform > distribution interleaved with drawing from the normal distribution. > > The basic scenario is doing some number of int draws from the uniform and > then doing 10 or so double draws from the normal. It looks like there is a > strange odd / even kind of behavior w/r to the number of uniform draws. For > example, if I do 7 draws from normal, I get: > > A, B, C, D, E, F, G > > where A etc. are some appropriately distributed random numbers. > > If I precede these draws with a SINGLE int draw from a uniform distribution, > and then do the normal draws I get: > > M, N, O, P, Q, R, S. > > That is, I get completely different numbers than in the first case. The > sequence is different. > > However, if I precede the normal draws with two int draws, and then do the > normal draws, I get: > > C, D, E, F, G, ... > > The point being that the sequence of normal draws is the same as the first > case. > > If I do three int uniform draws, and then do the normals, the sequence is > the same as that in the 1 int uniform draw case. I've tested this up to five > int draws and the pattern holds. > > So, I'm not sure this is a problem, but can anyone shed some light on this? > > thanks, > > Nick > > > ---------------------- > Nick Collier > Software Developer > Note New Email: nic...@ve... > > > |