help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mersenne Twister range in rand.oct and randn.oct


From: Mike Miller
Subject: Re: Mersenne Twister range in rand.oct and randn.oct
Date: Sun, 4 Dec 2005 01:28:00 -0600 (CST)

On Sat, 3 Dec 2005, Paul Kienzle wrote:

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);
}


OK. Thanks. I guess "(0,1)" means that neither 0 nor 1 will ever be generated as a random uniform, but does that last line of the code tell me the largest and smallest possible values for a random uniform? I can't figure out what the largest and smallest numbers would be.

Is it difficult to determine the range of possible values for the normal deviates (randn with mean 0 and variance 1 in Octave Forge)?

Thanks.

Mike



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]