Re: Seeding the pseudorandom number generator



chase321 wrote:
I have been using Gnumeric for some time in the statistics classes I teach. 
This past semester, I did my first online section, and had them submit labs
using Gnumeric.  For one lab, I had them use the "randbetween" function to
generate random numbers.  9 of the 17 labs I received had identical sets of
random numbers.  This makes me more than a little suspicious, but I have
also seen students get the same sequence of numbers in the classroom.  I
know enough about pseudorandom number generators to know that if two people
start at the same point in the sequence, they're going to get the same  set
of numbers.  So I have two questions.
1) How is the pseudorandom number generator initialized (seeded)?
2) Is there any way to seed it manually?  I can find no function for this
mentioned in the manual.

Thanks for any help.

Hi Chase,
Looking at the code in plugins/fn-random/functions.c and src/mathfunc.c
it appears rand_01 is the relevant function. By setting the environment
variable GNUMERIC_PRNG_SEED
(on unix with a bourne compatible shell with something like
$ export GNUMERIC_PRNG_SEED=some_random_string
) will cause rand_01 to use a pseudo random number generator using the
specified seed. Otherwise it should get its random numbers from /dev/urandom

My understanding of this is that if GNUMERIC_PRNG_SEED is set then each
time you open a sheet containing randbetween you will get the same
value, whereas if it isn't then you won't.

Are you using windows by any chance?

Kind regards,
Hal





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