[Ns-developers] ns3: random numbers
Mathieu Lacage
Mathieu.Lacage at sophia.inria.fr
Thu Mar 29 06:56:44 PDT 2007
hi raj,
I see that you have pushed recently the latest version of
RandomVariable. I have a few comments left:
1) I see that you have a #define INFINITE_VALUE at the top of
random-variable.h. I think that the likelyhood that someone else defines
a similar macro is not totally zero. I see that it is used in only one
place, NormalVariable so, it seems to me a nobrainer to remove it to
avoid any kind of potential problem:
- either replace it with a static const member variable in
NormalVariable
- or remove the default value in the NormalVariable constructor to
replace it with two separate constructors.
Patch which implements the former:
http://www-sop.inria.fr/dream/personnel/Mathieu.Lacage/random-var.patch
2) If I understood the API and the implementation correctly, I think
that:
- Seed is not used anymore in the implementation except to call
Seed::IsConstant once in RandomVariable::UseGlobalSeed which returns a
bool
- Seed is used in the API in one of two ways:
i) to specify a constant value to seed the seeding stream:
RandomVariable::UseGlobalSeed (ConstantSeed (2));
RandomVariable::UseGlobalSeed (ConstantSeed (2, 0, 1, 5, 6, 7));
ii) to specify that, if I called UseGlobalSeed (ConstantSeed (...))
before, I can revert to a random initial seed with UseGlobalSeed
(RandomSeed ());
I have to confess that I do not understand why you could not go with the
simpler version outlined below which gets rid of 3 extra class
definitions in the public API at the cost of an extra method
declaration:
class RandomVariable
{
static void UseGlobalConstantSeed (uint32 seed);
static void UseGlobalRandomSeed (void);
};
Mathieu
On Thu, 2007-03-15 at 11:54 -0400, Raj Bhattacharjea wrote:
> It seems discussion on this thread has wound down. Here is a brief summary
> of things that have been said, and their resolution:
>
> 1. Gustavo Carneiro had some concerns about naming, which were resolved.
> 2. Ruben Merz was wondering about GNU Scientific Library instead of
> L'Ecuyer's code. Tom Henderson pointed him to a previous thread discussing
> why the benefits of switching to GSL are not particularly great.
> 3. Michelle Weigle suggested a way to get multiple independent runs out of
> the same RNGs. George Riley and I decided on an implementation of her idea.
> 4. Michelle Weigle also suggested removing the ability to individually seed
> RNGs, which I accepted.
> 5. Mathieu Lacage had some concerns about implementing #3 above. He and
> Michelle had a discussion on the list resolving his concerns.
> 6. The issue of whether to seed "randomly" (based upon time, /dev/random,
> etc) or have a constant seed by default is *still open*. The feeling I get
> is that many want repeatable results by default to make debugging easier,
> while others believe that random variables should be random run to run. I
> don't have a strong feeling on this either way, although I lean towards
> default random behavior, with the user specifying when he or she wants
> repeatability via a GlobalSeed. As long as the API is clear about what is
> the default behavior and how one can change it, I think it will be fine
> either way.
>
> If no one else has any concerns, I will be implementing the changes
> mentioned previously, namely removing individual RNG seeding and getting
> multiple repeatable independent runs. I'd like to hear if anyone has more
> compelling arguments about default random vs. predictable behavior.
>
>
--
More information about the Ns-developers
mailing list