On Jul 9, 9:31*am, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Jul 8, 10:23*am, Clay <c...@claysturner.com> wrote:
>
>
>
>
>
> > On Jul 8, 8:36*am, robert bristow-johnson <r...@audioimagination.com>
> > wrote:
>
> > > On Jul 7, 2:08*pm, Clay <c...@claysturner.com> wrote:
>
> > > ...
>
> > > > When I think about generating a MAXIMUM length sequence, I woudn't
> > > > even consider something so short as just 4095 states before repeating.
> > > > I often use a Mersenne Twister, which has a period of 2^19937. Yes
> > > > that's correct.
>
> > > how does it work? *i cannot imagine it having a period of 2^m without
> > > it having a state that is at least m bits wide. *does it stroll
> > > through 19937 bits repeatedly?
>
> > Of course it has 19937 bits in memory - that is only 624 words (32
> > bits each). This may be an issue in a memory limited application, but
> > on a general computer not a problem at all. It uses a basic shift
> > register with feedback, but unlike common schemes, the feed back is
> > "twisted."
>
> > The Wiki article may help describe it for you. The pseudo code is
> > pretty simple to follow
>
> >http://en.wikipedia.org/wiki/Mersenne_twister
>
> so a pseudo-statement like:
>
> "int y := 32nd bit of(MT[i]) + last 31 bits of(MT[(i+1) mod 624])"
>
> means that the 32nd bit of MT[i] remains in the 32nd place in y (the
> MSB) and the lower 31 bits of (MT[(i+1) mod 624] go into the lower 31
> bits of y? *and does the multiplication in initializeGenerator()
> involve a (long long) or (unsigned long long) type?
>
> it also appears that extractNumber() is essentially a table lookup
> (with a pretty damn big table) in that it is only a function of MT
> [index] and it does not affect the generation of MT[]. *is that bit
> scrambling really necessary? *then, if it *is* necessary (the words
> would not look random enough without the bit scrambling), the question
> is, is it sufficient?
>
> just curious (and ignorant).
>
> r b-j- Hide quoted text -
>
> - Show quoted text -
Hello Robert,
1st we note that 19937 bits is 623 complete 32 bit words plus 1 extra
bit.
Basically the MT does bit scrambling on each of the 623 words ontil
which time you shift down (but not simple linear shifting) the whole
19937 bits.
I would say that both of these stages are necessary to ensure the
statistical properties.
One of the problems with standard linear congruence modulo generators,
was you could take pairs of numbers and then use one as an x value and
the other as a y value and plot a spot at (x,y). With an LCM
generator, the plotted spots would all appear on straight lines. So
there was a strong sample to sample correlation. And a lot has been
done to make scramblers to remove this correlation.
The MT picks consecutive numbers from different points in the 623
word chain. So this removes the sample to sample correlation. Once you
have made 623 picks, then a new 623 word chain is formed.
Note the efficiency in this process, that the overall data chain
"shifting" occures once every 623 calls! Common "C" implementations of
the MT actually run faster than the system supplied rand() function.
And yes unsigned 32 bit numbers are being used.
In the authors' seminal paper on the MT, the paper's title alludes to
the lack of sample to sample correlation for sets of up to 623 - 32
bit samples!
IHTH,
Clay