This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libfortran/52879] Pathological reseeding of PRNG generator genernates poor sequence


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52879

--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> ---
To be honest, I'm not sure that this test program really tests anything
sensible. There is no rule in the secret black book of PRNG algorithm design,
nor in the Fortran standard, that generating a single value must touch all the
seed variables. That is, you cannot change one element of the seed array,
generate ONE random number, see that the generated number doesn't change, and
conclude that the PRNG is in some kind of pathological state.

One way to test whether the seed is pathological would be to follow section 9.2
in http://vigna.di.unimi.it/ftp/papers/xorshift.pdf . That is, generate a
stream of random numbers, doing a rolling average, and see how quickly the
average converges towards 0.5. If the seed isn't pathological, you should hover
around 0.5 from the start, if it's poor xorshift1024* should converge within a
few hundred iterations.

Now, since https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=239613 the
PRNG should be a little more resistant poor seeds due to laziness or accident,
but there are of course still ways to generate poor seeds for someone
determined to shoot themselves in the foot (left as an exercise for the
reader).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]