[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Query: Spatially uncorrelated reproducible random values
From: |
Paul E Johnson |
Subject: |
Re: Query: Spatially uncorrelated reproducible random values |
Date: |
Thu, 03 Aug 2000 08:51:48 -0500 |
Nigel Gilbert wrote:
>
> Do you know that there is no correlation between a seed
> and the (next) generated value, or is this just an assumption you've
> made?
NO, I was just shooting from the hip. Jan B wrote to me with the same
point. I think I would have to experiment with it. Since you have only
the goal of a number uncorrelated with the x,y position, I suppose I'd
test it after taking a couple of precautions. Instead of using the
first draw after reseeding at a point, I'd use the 10th number drawn for
each position. I think I saw a note from Ted Belding a while back on
this question. Perhaps Ted or Sven Thomessen is reading this thread and
can give us a definitive answer.
I suppose the meaning of "correlated" is open to debate here. Obviously,
using my suggestion, the values will be related to x,y because a known
process is used to generate the value from the coordinate. But it could
be uncorrelated, in a second sense that, to the observer, it is not
possible to predict the random value without knowing the formula. I
think this is the meaning of pseudo-randomness (or is it quasi
randomness).
I'm looking at the code for Swarm's MT19937 generator (thanks, Sven) and
when it draws a number on the basis of the state (or, at first, the
seed), it does the following. I had the bit math on the top of my
tongue last month when I was doing the ArtificialStockMarket revision,
but the details have escaped me now, but it appears to me that the
numbers drawn after seeding are uncorrelated in the second sense above:
if (index == N)
{
/* generate N words at one time */
unsigned kk;
for (kk = 0; kk < N - M; kk++)
{
y = (state[kk]&UPPER_MASK)|(state[kk+1]&LOWER_MASK);
state[kk] = state[kk+M] ^ (y >> 1) ^ a[y & 0x1];
}
for (; kk < N - 1; kk++)
{
y = (state[kk]&UPPER_MASK)|(state[kk+1]&LOWER_MASK);
state[kk] = state[kk+(M-N)] ^ (y >> 1) ^ a[y & 0x1];
}
y = (state[N-1] & UPPER_MASK) | (state[0] & LOWER_MASK);
state[N - 1] = state[M - 1] ^ (y >> 1) ^ a[y & 0x1];
index = 0; // on subsequent rounds we start at 0
}
y = state[index++];
y ^= ( y >> TEMPERING_SHIFT_U );
y ^= ( ( y << TEMPERING_SHIFT_S ) & TEMPERING_MASK_B );
y ^= ( ( y << TEMPERING_SHIFT_T ) & TEMPERING_MASK_C );
y &= 0xffffffff; /* you may delete this line if word size = 32 */
y ^= ( y >> TEMPERING_SHIFT_L );
// -----------
if (antiThetic)
return (unsignedMax - y);
else
return y;
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700
==================================
Swarm-Modelling is for discussion of Simulation and Modelling techniques
esp. using Swarm. For list administration needs (esp. [un]subscribing),
please send a message to <address@hidden> with "help" in the
body of the message.
==================================