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

about the random number generator




Hi,

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.

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. 

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.

Thanks very much for your great tool.
-Sue