[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: about the random number generator
On Mon, 15 Sep 1997 16:42:21 EDT, "Sue B. Moon" wrote:
>I have been using ns-1.0b4 and on for my research,
>and enjoyed it a lot. While preparing to use ns-2 for my simulation,
>I got interested in the random number generators,
>and took a closer look at the one in ns.
Thanks for the interest; we just added the RNG in the last release.
>The RNG generator in ns-2 is decent, and easily implementable
>on any machine with 32-bit integers.
>The generator, however, has a weakness when it comes
>to statistical randomness tests, which is mentioned in the
>CACM paper. In A.M. Law and W. D. Kelton's "Simulation Modeling
>and Analysis", they recommend a different value 630360016 for "a",
>which is statistically superior than a=16807 currently used in ns-2.
>They provide a implementation technique called "simulated division,"
>and provide the C source code for it, that is
>portable on any 32-bit integer platform. I have included it below.
>
>The seeds in the seed table of Law & Kelton's generator are
>distanced at 100,000, and this information can be very useful
>for users who know approximately how many random numbers they use
>in one stream, and don't want to make two streams overlap if one
>is to be longer than 100,000.
>
>I am no number-theory expert, but at least this random number
>generator is better than the current one with a=16807.
>Since the code is readily available, and most ns users will run serious
>simulations, I think it's worthwhile to invest in a good random number
>generator.
Getting a good RNG is important to us.
I'm no number-theory expert either, but it looks to me like
your RNG is the basically same mechanism as the one in ns 2.0
with a different initial seed. My understanding was that the seed
A=16807 had a known long period, so I'm not sure what weakness you're
refering to. Both of the CACM papers referred to in rng.cc suggest
that A=16807 is not a bad choice.
Wrt a pre-spaced seed table, rng.cc already implements a table of
seeds ~33M steps apart, although with an initial vaule of 16807.
>One last note: I think it'd be good to have a warning to setting
>a seed heuristically, because it renders the experiment not re-generatable.
This is mentioned in the man page. If you have a suggestion (or a
patch) to make it more clear, we'd be happy to consider it.
I'm hestitant to clutter up the run-time output with lots of warnings.
-John Heidemann