-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm writing some code right now in which a parameter is meant to
fluctuate as a random walk. I'm using ran2 as the rng.
Suppose I write a simple piece of code of the form,
{
int i; double walk, increment;
/* initialise variables */
for(i=0;i<N;++i) {
walk += (ran2_get_double() < 0.5)?-increment:increment;
printf("%g\n",walk);
}
}
This code produces a nice random walk.
Suppose now instead I add to this,
{
int i; double walk, increment;
/* initialise variables */
for(i=0;i<N;++i) {
walk += (ran2_get_double() < 0.5)?-increment:increment;
printf("%g\n",walk);
/* A load of other stuff now happens here,
that also involves the generation of random
numbers with ran2. */
}
}
I've found that the random walk now has huge biases in it.
Can anyone explain why this should be so? Am I doing something
outrageously stupid by letting the random walk and the other material be
generated by the same stream of pseudo-random numbers?
Many thanks,
-- Joe
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFErjZtcjylL0sfzuERAuC4AJ9aWnsQxsevN8q/aijlks0z9HqkggCeI+9H
2rVJW7w0wOmpTbNUs6+Vr3o=
=JI6f
-----END PGP SIGNATURE-----
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl