[vox-tech] random number in C

Peter Jay Salzman vox-tech@lists.lugod.org
Tue, 2 Apr 2002 10:05:34 -0800


i wrote some monte carlo code which obtains a random generator seed
through a read to /dev/random.

on a lark, i did a run:

	T: 4.0e+00  beta: 2.500e-01  trials: 1000000
	N: 10  M: 10  seed: 208006379
	Average Energy: -1.057143
	Average magnetization: 0.002008
	Average |magnetization|: 0.251765
	Average magnetic susceptibility: 8.948655

and then in my code, i commented out the read to /dev/random and
assigned the seed to what it was above, 208006379.   i then ran the
program again:

	T: 4.0e+00  beta: 2.500e-01  trials: 1000000
	N: 10  M: 10  seed: 208006379
	Average Energy: -1.050182
	Average magnetization: 0.030723
	Average |magnetization|: 0.246092
	Average magnetic susceptibility: 8.692724

the seed for these two runs is the same.  i would've expected that calls
to rand() should've generated the same set of random numbers.  yet the
different runs of the monte carlo code yield different results, which is
fine, except i was expecting it to be exactly the same since the seed is
the same.

am i wrong about seeds yielding different sets of random numbers?

any thoughts?

it would be nice to "redo" a run.  i was under the impression that for
identical input (just the temperature) and an identical seed, two runs
should be exactly the same...

pete