|
From: Nick C. <nic...@ve...> - 2004-10-15 21:27:37
|
Curious random number behaviorI made a quick test case to investigate this
further. It looks with seed 4 (and maybe others), there is a strange odd /
even kind of behavior w/r to the skips. By this I mean that the first draw
from normal after 2 skips is the 3rd item in a 0 skip draw, and the first
draw from normal after 4 skips is the fifth item in a 0 skip draw.
Similarly, the first draw after 3 skips is the 3rd item in a 1 skip draw.
But the two "odd" and "even" streams are not the same. I'm not sure if this
is erroneous behavior, although it might be, given that if you use the same
seed and do the same number and kind of draws you end up with the same
behavior.
Note that if the skip does a draw from normal, this behavior does NOT occur.
At any rate, repast uses the colt library for random number generation and
I'll poke around that and see what I can find out.
Nick
-----Original Message-----
From: rep...@li...
[mailto:rep...@li...]On Behalf Of Beyeler,
Walter E
Sent: Friday, October 15, 2004 4:44 PM
To: rep...@li...
Subject: [Repast-developer] Curious random number behavior
Our model creates a random network, then imposes a random pattern of
sources and sinks. We want to try various source/sink stressors on the same
network, and do this by throwing away a specified number of random samples
between the network generation and the stress generation. Different numbers
of discards give us different source/sink patterns. The odd result is that
for some random seeds we get the identical sequence of sampled values
following two different numbers of discarded samples. The relevant section
of code is:
private void discardSamples(Element parameterDefinition) {
String spareSamples =
parameterDefinition.getAttributeValue("randomOffset");
if (spareSamples != null) {
int skips = (int)Double.parseDouble(spareSamples);
for (int i=0; i < skips; i++) {
System.out.print("Skipping
"+Random.uniform.nextInt()+"\n");
}
for (int i=0; i < 10; i++) {
System.out.print("Testing
"+Random.normal.nextDouble(0.0,1.0)+"\n");
}
}
}
The attached file shows some output for "seed 4" after discarding 1, 3,
and 2 samples, and for a second seed "seed 1" after discarding 1, 3, and 2
samples. In particular for"seed 4", we see the same sample values if we
throw away one sample or three samples. If we throw away two samples, the
subsequent samples differ. For "seed 1", the samples following 3 discards
are offset from those following 1 discard by 1 value, while the sequence
following 2 discards seems unrelated to the other sequences. The latter
result for "seed 1" perhaps makes sense since the discards are samples of
integers while the "real" samples are double precision values, but I can't
understand the "seed 4" results at all. Any leads would be welcome...
Walt Beyeler
Sandia National Laboratories, Albuquerque, NM
<<PuzzlingOutput.txt>>
|