Cascaded integrator-comb (CIC) filters are used in decimators, and decimators with a gain that is a power of 2 are popular (at least at my workplace) because the gain can be normalized with a right shift of the output data.

My understanding of decimators comes from Discrete Time Signal Processing by Alan Oppenheim, where decimators are described as a low pass anti-alias filter (AAF) followed by a rate reducer. The Rick Lyons article linked below states that a first order CIC decimator is equivalent to a moving average filter followed by a rate reducer.


How does rate reduction in a CIC decimator with even valued gain work if a moving average filter with even length impulse response has a non-integer group delay?

For example, taking a decimation ratio of 5, the anti-alias filter's impulse response would be [1,1,1,1,1], and the rate reducer would select every 5th sample starting with the 3rd one because the AAF has a group delay of 2. But what if the decimation ratio was 4? The rate reducer would select every 4th sample, but would it start with the second sample or the third? The group delay is 1.5, so we should start with the 2.5th sample, but it doesn't exist.


1 Answer 1


As the OP has noted and as detailed further here, the CIC decimator is mathematically identical to a moving average filter followed by a down sampler.

In the structure of a moving average filter followed by a down sampler, the group delay does not dictate which sample you pick. In the OP's example of a 5 sample moving average, the group delay is indeed two samples as the OP has stated, so a sampled sine wave for example would appear with a two sample delay at the output of the moving average. However regardless of this delay, we can still choose to down-sample starting with ANY sample with the result that the down-sampled waveform will just be an additional delayed copy of the waveform for any other starting sample selected (so we get in this case the choice of five possible delays for the same output waveform). I demonstrate this with a simple sinusoidal test waveform in the graphic below:

5 sample example

In the upper graph we see the input signal and signal after the 5 sample moving average where the 2 sample delay occurs. In the lower plot shows the options for the output waveform depending on which sample we start with: "start = 0" means we select the very first sample out of the moving average filter output (which would be the first sample at the input given $y[n]=x[n]+x[n-1]+x[n-2]+x[n-3]+x[n-4]$), and then every 5th sample after that. "start =1" means we start with the second sample and then select every 5th sample after that, etc. Note that the resulting output is still the same waveform, just representing how it appears at a different delay in time. In this case each of those possible outputs already includes the filter group delay, and then we can optionally add more delay depending on which sample we start with (with reference to the output sampling rate), simply as samples of the delayed waveform.

In case the fractional delay itself was a point of confusion for the OP: When we have a filter that includes a 1/2 sample delay, this means the samples at the output of the filter will be the interpolated values midway between the original input samples. The down sampling of this will simply be samples selected from this delayed waveform. This is the same result to having delayed the analog waveform by 1.5 samples prior to sampling. I demonstrate the point I am trying to make with the two plots below, here showing the result of a 4 sample moving average (thus group delay = 1.5 samples) of the same waveform used above, but also divided by 4 so that we can compare input vs output directly.

First observe the zoomed out plot where we see the output delayed by 1.5 samples:

zoom out 4 sample moving average

I zoom in on the waveforms in the plot below to show that the output samples with the 1.5 sample delay are indeed the expected samples in the waveform 1.5 samples earlier, as values that did not originally exist--they are simply the interpolated values associated with that fractional delay. That said, the subsequent down sampling we do will be on these new values regardless of what the group delay of the filter was: if we start sooner or later it just adjusts the final delay of the output but this is the same whether we have an integer or fractional group delay in the moving average filter.

Zoom in

Consider a simple case of a moving average filter of 2 samples, and we down sample by selecting every other sample: We can select either the even samples OR the odd samples at the output of the two sample moving average. Within the bandwidth of the decimation, the two waveforms are identical other than the difference in phase associated with the one sample offset (one sample offset at the input sampling rate). Further, prior to down sampling, the delay at the output of the 2 sample moving average will be one half a sample at the input sampling rate: the group delay of any symmetric or antisymmetric filter (in this case with coefficients [1 1]) is $(N-1)/2$ where $N$ is the number of coefficients (here 2).

That said, we see in this example, relative to the input sampling rate the delay at the output of the two sample moving average is 0.5 samples. We then select either even or odd samples which will have an 1 sample delay between them (at the input sampling rate).

A diagram depicting this is shown below, where the group delays shown are given in units of the input sampling rate. Assuming the down-samplers operate concurrently, selecting the "odd" samples is similar to a 1 sample delay of the output of the 2 sample moving average prior to down sampling. The two outputs shown will be identical with regards to signal content within the decimated spectrum other than a linear phase difference consistent with the 1 sample delay between them.

Decimate by 2

In units of samples at the output sampling rate, the group delays shown at the output would therefore be half of what is shown or -.75 samples and -.25 samples. This is just the resulting delay of the filter depending on which output is chosen (which starting value is chosen for down sampling) but either will result in the resampled waveform at the lower rate with the appropriately interpolated values given by that fractional delay.

  • $\begingroup$ Regarding your first figure, it is interesting that only decimated outputs with start >= group delay resemble a sine without a ramp up from zero (i.e. accurately represent the input). This might be a coincidence of you doing a "same" length convolution. Thanks for the great answer! $\endgroup$
    – DavidG25
    Commented Mar 30, 2023 at 16:10
  • $\begingroup$ @DavidG25 Nice observation. Notice that they ALL include some transient artifact. To completely eliminate the transient in any filter you need to truncate the resulting output by the length of the filter. This is different from the group delay which represents how the waveform is delayed in time as it goes through the filter. We can truncate to eliminate the group delay (align input with output), but we will still see a transient in the beginning. Just consider when the signal gets half way through in the beginning, the remaining samples in the filter are still 0, so output is still "settling" $\endgroup$ Commented Mar 30, 2023 at 16:25
  • $\begingroup$ Right, but I think since you did something like np.convolve(input, IR, mode="same") (at least the input and output look like they're the same length), you're already missing the first (N-1)/2 samples. Throwing away another (N-1)/2 effectively truncates the output by the length of the filter. I don't think there is any transient artifact in start >= 3. $\endgroup$
    – DavidG25
    Commented Mar 30, 2023 at 16:36
  • $\begingroup$ @DavidG25 I didn't truncate, I am plotting all samples that appear at input and output starting at the same time. I used sig.lfilter([1,1,1,1,1], 1, x) $\endgroup$ Commented Mar 30, 2023 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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