Discussion:
[SciPy-Dev] Maximum length sequence
Eric Larson
2014-02-18 17:40:36 UTC
Permalink
Maximum length sequences (MLS) are useful in signal processing for finding
impulse responses. I can't find a great implementation of MLS in Python,
but maybe I've missed one somewhere. Would this be something good to put in
scipy.signal, perhaps as scipy.signal.mls?

Cheers,
Eric
Neal Becker
2014-02-19 13:37:20 UTC
Permalink
Post by Eric Larson
Maximum length sequences (MLS) are useful in signal processing for finding
impulse responses. I can't find a great implementation of MLS in Python,
but maybe I've missed one somewhere. Would this be something good to put in
scipy.signal, perhaps as scipy.signal.mls?
Cheers,
Eric
If you want a sequence of gaussian rv, just use numpy.random.
Robert Kern
2014-02-19 13:39:28 UTC
Permalink
Post by Neal Becker
Post by Eric Larson
Maximum length sequences (MLS) are useful in signal processing for finding
impulse responses. I can't find a great implementation of MLS in Python,
but maybe I've missed one somewhere. Would this be something good to put in
scipy.signal, perhaps as scipy.signal.mls?
Cheers,
Eric
If you want a sequence of gaussian rv, just use numpy.random.
That does not appear to be what he wants:

http://en.wikipedia.org/wiki/Maximum_length_sequence
--
Robert Kern
Neal Becker
2014-02-21 21:27:52 UTC
Permalink
Post by Robert Kern
Post by Neal Becker
Post by Eric Larson
Maximum length sequences (MLS) are useful in signal processing for finding
impulse responses. I can't find a great implementation of MLS in Python,
but maybe I've missed one somewhere. Would this be something good to put in
scipy.signal, perhaps as scipy.signal.mls?
Cheers,
Eric
If you want a sequence of gaussian rv, just use numpy.random.
http://en.wikipedia.org/wiki/Maximum_length_sequence
I'm assuming what's wanted here is white noise.

To generate random bits of some specified bit width, I use the underlying
mersenne twister to generate uniform integer r.v., then cache the bits (32 at a
time) and output them with the desired width.

Of course this is not identical to what the OP asked, but serves the same
purpose.

A snippet of the C++ code used for this looks like:

template<class Engine>
result_type operator() (Engine& eng) {


if (count <= width-1) {
cache = eng();
count = std::min (std::numeric_limits<typename
Engine::result_type>::digits, std::numeric_limits<result_type>::digits);
}
result_type bits = cache & mask;
cache >>= width;
count -= width;
return bits;
}
Eric Larson
2014-02-21 21:50:32 UTC
Permalink
MLS has specific properties that make it especially well suited to finding
impulse responses of systems. I appreciate the suggestion of using white
noise, but some MLS properties (binary representation, systematic noise
cancellation through repetitions, true rather than on average white
spectrum) make it a preferred option in applications like acoustics (for
speaker impulse responses) and even neuroscience (e.g., for finding
auditory brainstem responses). I can try to track down relevant references
if you're really interested.

Eric
Post by Eric Larson
Post by Robert Kern
Post by Neal Becker
Post by Eric Larson
Maximum length sequences (MLS) are useful in signal processing for
finding
Post by Robert Kern
Post by Neal Becker
Post by Eric Larson
impulse responses. I can't find a great implementation of MLS in
Python,
Post by Robert Kern
Post by Neal Becker
Post by Eric Larson
but maybe I've missed one somewhere. Would this be something good to
put in
Post by Robert Kern
Post by Neal Becker
Post by Eric Larson
scipy.signal, perhaps as scipy.signal.mls?
Cheers,
Eric
If you want a sequence of gaussian rv, just use numpy.random.
http://en.wikipedia.org/wiki/Maximum_length_sequence
I'm assuming what's wanted here is white noise.
To generate random bits of some specified bit width, I use the underlying
mersenne twister to generate uniform integer r.v., then cache the bits (32 at a
time) and output them with the desired width.
Of course this is not identical to what the OP asked, but serves the same
purpose.
template<class Engine>
result_type operator() (Engine& eng) {
if (count <= width-1) {
cache = eng();
count = std::min (std::numeric_limits<typename
Engine::result_type>::digits, std::numeric_limits<result_type>::digits);
}
result_type bits = cache & mask;
cache >>= width;
count -= width;
return bits;
}
_______________________________________________
SciPy-Dev mailing list
http://mail.scipy.org/mailman/listinfo/scipy-dev
Pierre Haessig
2014-02-19 14:40:22 UTC
Permalink
Hi,
Post by Eric Larson
Maximum length sequences (MLS) are useful in signal processing for
finding impulse responses. I can't find a great implementation of MLS
in Python, but maybe I've missed one somewhere. Would this be
something good to put in scipy.signal, perhaps as scipy.signal.mls?
scipy.signal seems the right place to me.

Just a name idea : scipy.signal.max_len_seq ?
(to avoid yet another acronym)

best,
Pierre
Eric Larson
2014-02-19 16:55:13 UTC
Permalink
Thanks for the ideas. I've opened a PR:

https://github.com/scipy/scipy/pull/3351

Indeed I specifically want MLS as opposed to Gaussian noise as MLS has some
properties that make it nice for finding impluse responses (e.g., in
acoustics and neuroscience). I've changed the name in the PR to
`max_len_seq` from `mls`, feel free to comment on the PR if people have
other ideas.

Cheers,
Eric
Post by Pierre Haessig
Hi,
Post by Eric Larson
Maximum length sequences (MLS) are useful in signal processing for
finding impulse responses. I can't find a great implementation of MLS
in Python, but maybe I've missed one somewhere. Would this be
something good to put in scipy.signal, perhaps as scipy.signal.mls?
scipy.signal seems the right place to me.
Just a name idea : scipy.signal.max_len_seq ?
(to avoid yet another acronym)
best,
Pierre
_______________________________________________
SciPy-Dev mailing list
http://mail.scipy.org/mailman/listinfo/scipy-dev
Continue reading on narkive:
Loading...