Module providing the functionality to generate Maximal Length Sequences. Based on wiki’s description and polynomial representation. http://en.wikipedia.org/wiki/Maximum_length_sequence
import numpy
import pylab
from sp import mls
from sp import filter
nbits = 9
m = mls.mls(nbits)
pylab.figure()
pylab.title('%d bit M-Sequence Periodic Autocorrelation' % nbits)
m = numpy.where(m, 1.0, -1.0)
pylab.plot((numpy.roll(filter.ccorr(m, m).real, 2**nbits/2 - 1)))
pylab.xlim(0, len(m))
pylab.show()
(Source code, png, hires.png, pdf)
See the individual methods below for further details.