I have a 1D signal that is roughly periodical (but not exactly) - think of some kind of motion that someone performs repeatedly, and which is measured by some sensor.

I am looking for a way to

  • automatically chop up the signal into the individual cycles, and
  • somehow calculate an "average" that preserves the characteristics of the measured motion

How could this be done?

  • 2
    $\begingroup$ Do you know the (at least approximate) period? Is there significant noise contained in the measurements? $\endgroup$
    – Jason R
    Oct 25 '11 at 12:06
  • $\begingroup$ Can you describe the signal in more detail? Where does a cycle start and stop ? Does your chunk have to line up with an entire cycle, or could it start and end halfway through a cycle? $\endgroup$
    – endolith
    Oct 25 '11 at 13:12

What you need to achieve is to estimate the typical periodicity of a cycle. What is required is to do harmonic analysis on the same.

There are few things - i am making assumption which is critical to your solution. 1. Signal you have is not a fixed analytical expression but some arbitrary format.

  1. We don't quite know a prior what could be the range of periodicity.

  2. It is periodic but not perfectly - so we should rather treat it is a random process rather than a pure analytical function. There is probably noise at play as well - but we will worry about it a bit later.

  3. We need to implement such a system - so we are more interested in discrete time representation of signal and a device to detect such periodicity rather than analytic solution of the given arbitrary function in continuous time.

To describe the solution - we shall start the other way and include each assumption.

a. Case for perfect periodic signal. Suppose if you have a pure sine wave of a frequency say Omega - W. Since it is expressed as an infinite time continuous sequence, the frequency domain is a finite spectrum - which is pure impulse. So If we can observe the signal in a frequency domain - the position of the said impulse is nothing but the periodicity of the wave form. That's quite easy.

When the signal is sampled (as it would be in real world) as opposed to an analytical form - the resultant frequency response is Discrete Time Fourier Transform - where one see continuous lobes rather than impulses in frequency domain. Here the dominant and subordinates lobes are equivalent to the frequency impulses earlier.

b. what if the signal is not analytic form but arbitrary Now consider a case of the square wave or any such similar function. For a square wave what you will see is that now you will have many more harmonics. But you will notice one important thing. The primary harmonic you will observe will be also the one which has highest energy - and THAT is also the periodicity. This is usually known as Dominant harmonic. For any arbitrary signal we need to consider DOMINANT harmonic which is the best approximation of the frequency.

c. when signal is not perfectly periodic When the signal is not perfectly periodic, the observation in frequency spectrum is time varying. In such cases, the primary dominant frequency component will fluctuate around the most expected periodicity. If the periodicity is firm - only shape varies - the location of the dominant component will be static but magnitude of all critical composition will vary. If the periodicity also fluctuates - the same fluctuation will be visible in the position of the frequency component and consequently one needs to "track" such a change over time which is the information we are seeking essentially.

So looking at a, b, and c - the conclusion is simpler - find the dominant principle component (and track it).

d. when the signal is finite time When the signal is finite in time - the spectrum is infinite - in such cases one usually cannot hope to plot the infinitely long frequency spectrum. However, typically the approaches with finding Segment wise is to have apply the STFT domain

Now here is the catch. What should be the Finite time window for which Finite frequency spectrum should be calculated? The simple answer is the larger the periodicity - even larger needs to be the size of the window. This is equivalent of Nyquist criteria but not exactly same. In order to capture the real periodicity - multiple dominant cycles must be visible in the given Time window span - to ensure that frequency of measured accurately. However, this means that period for which periodicity is measured is larger than a few cycles at least; but this means resolution of change estimate is lesser. Higher the period higher the accuracy - lesser the resolution of change! This is known as uncertainty principle.

Of course, a large number of approaches to do pitch detection from a speech signal does exactly this - and most tools use STFT.

Over time- of course, more modern way of doing things are based on wavelet based approaches. Wavelets doesn't eliminate the uncertainty principle but just hope to get you closest combination of resolution and accuracy.



You can probably use autocorrelation to get an approximate cycle length, if you don't know it already. Then search around that length for zero crossings or local maxima or whatever signifies the beginning of a cycle. You need to describe the signal in more detail.


You can use "zero crossing detection" to segment your signal. Provided each of the segments are of equal length, i.e, you have a periodic signal, you can then get the point by point mean of all segments. If on the other hand, your segments are of different lengths, you may need to normalise the length of each segment using resampling or something more exotic if each period of the signal has variable characteristics.


An alternative to "chopping up" and averaging a "roughly" periodic signal might be frequency domain analysis and resynthesis.

Window some (large enough) multiple of periods, calculate the FFT, extract an estimate of the fundamental frequency (perhaps an interpolated peak), plus the estimated peak component of all the significant harmonics, plus the phase of these harmonics relative to the fundamental, discard everything else not related to your chosen fundamental period, then use the overtone series for the resynthesis one "template" period.

Note that the fundamental frequency might be missing or nearly so, and, if so, that you may have to guess the roughly correct range of the fundamental frequency to avoid the infinite suboctave or subharmonic problem. This would be true with autocorrelation analysis as well.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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