From help-request at octave dot org Sat Dec 3 18:47:41 2005 Subject: Re: Mersenne Twister range in rand.oct and randn.oct From: Paul Kienzle To: Mike Miller Cc: Help-Octave List Date: Sat, 3 Dec 2005 19:44:21 -0500 On Dec 1, 2005, at 9:58 AM, Mike Miller wrote: > On Thu, 1 Dec 2005, Mike Miller wrote: > >> In one Mersenne Twister FAQ I see this: >> >> 2002-version mt19937ar.c has versions [0,1],[0,1),[0,1),(0,1) >> (32-bit >> precision), and [0,1) with 53-bit precision. >> >> Which am I getting when I use rand.oct in Octave forge? What I would >> really like to know are the largest and smallest values that can be >> produced both by rand.oct and by randn.oct. > > > I should say that it's really one .oct file: rand.oct. > randn is derived from rand.oct. > > I took a look at Octave Forge's rand.cc but I can't find in it what I > need to know (because of my incompetence, obviously). The answer is in Makefile rather than rand.cc. This sets the ALL_BITS flag for building randmtzig.c. Here's the relevant code: /* generates a random number on (0,1) with 53-bit resolution */ USE_INLINE double randu53(void) { const uint32_t a=randi32()>>5; const uint32_t b=randi32()>>6; return(a*67108864.0+b+0.4) * (1.0/9007199254740992.0); } - Paul ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------