FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #26 (permalink)  
Old 07-08-2009, 07:51 AM
Nicholas Kinar
Guest
 
Posts: n/a
Default Re: Generating Maximum Length Sequence using Galois LFSR


>
> 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. And it is easy to implement and free code exist on the
> web for it. The inventor (Makoto Matsumoto ) put it (code and
> algorithm) into the public domain, so you are free to use it without
> worry about IP issues. And statistically, the Twister's output fairs
> better on statistics tests than stuff from a simple loopback of a
> shift register with some exclusive ors. You may want to look into
> this.
>
> Clay



Thanks Clay; that's a really neat algorithm! It's certainly something
to think about when doing statistical tests. The large period is just
amazing.


Reply With Quote
  #27 (permalink)  
Old 07-08-2009, 02:36 PM
robert bristow-johnson
Guest
 
Posts: n/a
Default Re: Generating Maximum Length Sequence using Galois LFSR

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?

r b-j


Reply With Quote
  #28 (permalink)  
Old 07-08-2009, 04:23 PM
Clay
Guest
 
Posts: n/a
Default Re: Generating Maximum Length Sequence using Galois LFSR

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?
>
> r b-j


Hello Robert,

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

The paper "Mersenne twister: a 623-dimensionally equidistributed
uniform pseudo-random number generator" is the one where Makoto
Matsumoto and Takuji Nishimura first describe the method.

You may find the paper here:

http://www.math.sci.hiroshima-u.ac.j...RTICLES/mt.pdf

Enjoy!

Clay







Reply With Quote
  #29 (permalink)  
Old 07-09-2009, 03:31 PM
robert bristow-johnson
Guest
 
Posts: n/a
Default Re: Generating Maximum Length Sequence using Galois LFSR

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

Reply With Quote
  #30 (permalink)  
Old 07-09-2009, 05:41 PM
Clay
Guest
 
Posts: n/a
Default Re: Generating Maximum Length Sequence using Galois LFSR

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










Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating "Orthogonal" Sequences from a PN sequence [email protected] DSP 1 03-26-2009 03:57 PM
Difference between maximum likelihood and maximum aposterior probability dgse DSP 2 05-10-2007 05:22 PM
LFSR sequence sylvain DSP 4 01-17-2006 03:35 AM
Relationship between Fibonacci and Galois Implementation of Maximal Length Sequences Sastry DSP 2 05-20-2005 02:21 AM
M-sequence of length 63 porterboy DSP 8 12-20-2003 01:54 AM


All times are GMT +1. The time now is 04:01 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved