Re: Seeding the pseudorandom number generator

Hal Ashburner-2 wrote:

chase321 wrote:
I have been using Gnumeric for some time in the statistics classes I
This past semester, I did my first online section, and had them submit
using Gnumeric.  For one lab, I had them use the "randbetween" function
generate random numbers.  9 of the 17 labs I received had identical sets
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
start at the same point in the sequence, they're going to get the same 
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
(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

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,

I'm using Linux, but most if not all of my students are using Windows. 
What I actually had them do is generate the random numbers and then copy
and paste "as value" so the numbers would stay fixed for the rest of the
activity.  So I should be getting the actual numbers that they got.  Of
course, if one of them did the lab and then passed the finished product
around to the others, that would certainly explain it, but I don't want to
claim that if I'm not sure. 
Would the Windows installer set the environmental variable?  I can check
tomorrow to see if it's set on my Windows machine at the office.
Incidentally, grades are already in, so I won't be taking this to the dean
at this point, but  I would like to know what's going on.
Thanks for the quick reply!
gnumeric-list mailing list
gnumeric-list gnome org

View this message in context:
Sent from the GnuMeric mailing list archive at

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