1
$\begingroup$

I am new to DSP, and I am trying to recreate some analysis of a signal,

They use a chebyshev I filter to go from a 100Hz signal to a 50Hz signal. Whereas I am currently using a chebyshev II filter, however I have very little understanding of how they work, and the differences between them, and even if they do the same thing.

So my question is, firstly, how exactly does the chebyshev I filter decimate my signal?. And secondly what is the difference between that process and the chebyshev II filter and are they interchangeable? (my background is in maths if it affects the explanation)

$\endgroup$
  • 3
    $\begingroup$ Welcome to SE.SP! Filters, generally, don't decimate a signal... at least that's not their main purpose. By from a 100Hz signal to a 50Hz signal do you mean that the sampling rate changes from 100Hz to 50Hz? $\endgroup$ – Peter K. Mar 12 at 18:06
4
$\begingroup$

The decimation operation, under some acceptations, consists in low-pass filtering the data before downsampling it. The standard in Python scipy.signal.decimate, in Matlab decimate: Filtering Before Downsampling, or even in R [decimate] (but it is borrowed from Octave), is to use a Chebyshev type I (of order 8, 10 and 8 respectively).

In Matlab cheby1, or at Comparison of Classical IIR Filter Types , one can find comparative plots, such as:

comparative plots for IIR filters

Basically, Chebyshev filters aim at improving lowpass performance by allowing ripples in either the lowpass-band (Type I) or the highpass-band (Type II), whereas the behavior is monotonic in the complementary band.

With Type I, you are ensured that, if two frequency components in the highpass-band have the same amplitude, the highest frequency amplitude will be lower after filtering, which can be comforting when downsampling afterward. With Type II, you have the converse in the lowpass-band.

Personally (a kind of coming-out, and I'd be glad to be corrected by my colleagues):

  • if my data has precise high-frequency limit (esp. for lectures), and I'm pretty sure of the cutoff, I tend to use type I
  • if my data is quite imprecise, noisy, and I care more for relative amplitudes in the low-pass band, I tend to use type II (empirically) to reject the noise, even if I lose sharpness.

Edit from r b-j: Note in this modified plot, the cheby2 filter had its stopband frequency adjusted so that the -3.01 dB cutoff frequency coincides with the other three filters (and I normalized it to 1). Note that the 5th-order Type I and Type II Tchebyshev filters both transition from -3.01 dB (the edge of the passband) to -30 dB (the edge of the stopband) in exactly the same transition band from a normalized frequency of 1 (passband) to 1.364 (stopband).

So the Type I and Type II Tchebyshev filters have the same performance in terms of sharpness of cutoff, if you compare apples to apples. The main tradeoff between Type I and Type II is where the ripple is. In Type I, the ripple is in the passband (where I usually would rather not see it) and in Type II the ripple is in the stop band (where I usually don't care).

MATLAB code:

clear;
close all;

N = 5;
f0 = 1;
w0 = 2*pi*f0;

passband_gain = 10*log10(0.5);          % -3.01 dB (half power)
stopband_gain = -30;                    % dB

% Design a 5th-order analog Butterworth lowpass filter with a cutoff 
% frequency of 1 Hz. Multiply by  to convert the frequency to radians per 
% second. Compute the frequency response of the filter at 4096 points.

[zb,pb,kb] = butter(N, w0, 's');
[bb,ab] = zp2tf(zb,pb,kb);
[hb,wb] = freqs(bb,ab,4096);

% Design a 5th-order Chebyshev Type I filter with the same edge frequency 
% and 3.01 dB of passband ripple.

[z1,p1,k1] = cheby1(N, -passband_gain, w0, 's');
[b1,a1] = zp2tf(z1,p1,k1);
[h1,w1] = freqs(b1,a1,4096);

% Design a 5th-order Chebyshev Type II filter with the passband edge  
% frequency and 30 dB of stopband attenuation.

w_stopband = w0*cosh((1/N)*acosh(sqrt(10^(-stopband_gain/10)-1)));
[z2,p2,k2] = cheby2(N, -stopband_gain, w_stopband, 's');
[b2,a2] = zp2tf(z2,p2,k2);
[h2,w2] = freqs(b2,a2,4096);

% Design a 5th-order elliptic filter with the same edge frequency, 3.01 dB  
% of passband ripple, and 30 dB of stopband attenuation.

[ze,pe,ke] = ellip(N, -passband_gain, -stopband_gain, w0,'s');
[be,ae] = zp2tf(ze,pe,ke);
[he,we] = freqs(be,ae,4096);

% Plot the gain in decibels. Compare the filters.

plot(wb/(2*pi),mag2db(abs(hb)))
hold on
plot(w1/(2*pi),mag2db(abs(h1)))
plot(w2/(2*pi),mag2db(abs(h2)))
plot(we/(2*pi),mag2db(abs(he)))
hold off
axis([0 3 -40 5])
grid
xlabel('Frequency')
ylabel('Gain (dB)')
legend('butter','cheby1','cheby2','ellip')
$\endgroup$
  • 1
    $\begingroup$ @robert bristow-johnson Excellent edit, thank you $\endgroup$ – Laurent Duval Mar 13 at 9:07

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.