Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working with a signal which is a periodic square signal with some kind of noise and some outliers. I would like to know which is the best solution in order to get the period and clean the outliers that can be seen in the image:

enter image description here

The final goal is to binarize the signal.

Thanks in advance,

share|cite|improve this question
You should not ask the same question on two different stackexchanges. Please contact the moderators (click on the link marked flag at the bottom of your post) and ask them to migrate this question to dsp.SE which is a better fit. – Dilip Sarwate Feb 19 '13 at 14:11
up vote 1 down vote accepted

Here's what I would do:

  1. Lowpass filter the signal to remove the high-frequency noise.
  2. Once you lowpass filter the original signal, it won't look like a square wave anymore. The infinitely sharp transitions will be damped. Thus, apply a $1$-bit quantizer (with hysteresis) to the output of the lowpass filter, so that you "binarize" the lowpass filtered signal.
  3. Differentiate the "binarized" signal, in order to obtain a train of impulses. Compute the duration of the time intervals between successive impulses, compile a list of such durations, then compute a histogram, normalize the histogram, and then compute the 1st moment of the normalized histogram (which is an estimate of the expected value of the period).
share|cite|improve this answer
Dear Rod, I fully understand your answer and I guess it will work well. I will try it immediately. Thanks for your answer. – Dídac Pérez Parera Feb 19 '13 at 11:49
A median filter (instead of an average) could be better for step 1. – leonbloy Feb 19 '13 at 14:57
@leonbloy: It's hard to implement a median filter using analog electronics, though. – Rod Carvalho Feb 19 '13 at 19:12
@RodCarvalho Sure - it's also hard to compute histograms. But I don't see anything about analog electronics in the OP. – leonbloy Feb 19 '13 at 20:43
@leonbloy: You're right. The solution I proposed is arguably ugly, but implementable using analog electronics. It's how digital signals are regenerated (if I remember my communication systems classes properly). – Rod Carvalho Feb 19 '13 at 20:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.