# Create a minimum phase filter from an elliptic digital filter

I have the numerator and denominator of a lowpass digital elliptic filter. I know how to create a minimum-phase filter with the same magnitude response using cepstrum technique. But I came across this from Julius Smith III website.

dosounds = 1;
N = 8;     % filter order
Rp = 0.5;  % passband ripple (dB)
Rs = 60;   % stopband ripple (-dB)
Fs = 8192; % default sampling rate (Windows Matlab)
Fp = 2000; % passband end
Fc = 2200; % stopband begins [gives order 8]
Ns = 4096; % number of samples in impulse responses

[B,A] = nellip(Rp, Rs, Fp/(0.5*Fs), Fc/(0.5*Fs)); % Octave
% [B,A] = ellip(N, Rp, Rs, Fp/(0.5*Fs)); % Matlab

% Minimum phase case:
imp = [1,zeros(1,Ns/2-1)]; % or 'h1=impz(B,A,Ns/2-1)'
h1 = filter(B,A,imp); % min-phase impulse response
hmp = filter(B,A,[h1,zeros(1,Ns/2)]); % apply twice

% Zero phase case:
h1r = fliplr(h1); % maximum-phase impulse response
hzp = filter(B,A,[h1r,zeros(1,Ns/2)]); % min*max=zp
% hzp = fliplr(hzp); % not needed here since symmetric

elliptplots; % plot impulse- and amplitude-responses

% Let's hear them!
while(dosounds)
sound(hmp,Fs);
pause(0.5);
sound(hzp,Fs);
pause(1);
end


I tried to check minimum phase properties for hmp but hmp did not satisfy them. For example, I compare the cumulative energy of impulse responses hmp and the impulse response of the elliptic filter. Would someone please shed some light why hmp is a minimum phase.

• You don't tell us how you tried to check whether the filter is minimum phase, and how you failed to do so. Also, how should we know what you mean by hmp? All standard IIR filters obtained from transformation of analog prototypes are minimum phase. Do you know how to see this from the poles and zeros? Please edit your question so everybody can understand what exactly it is that you did and what exactly it is that you don't understand. Commented May 25 at 15:03
• @MattL. Thanks for your reply. There is a link to the code where hmp is computed but I also pasted to the question for the convenience. I’m trying to understand wht J. Smith refers to hmp a minimum phase response. I do know that zeros/poles of a MP filter lie inside the unit circle. For the elliptic filter, the zeros are on the unit circle which makes the filter marginally MP.
– AHT
Commented May 25 at 15:43
• @MattL. "All standard IIR filters .. are minimum phase". I'm not sure this is true. They often have zeros ON the unit circle, that means are not invertible, Commented May 25 at 16:04
• hmp is the impulse response corresponding to the square of the transfer function of the elliptic filter. The elliptic filter is minimum phase (ok, with zeros on the unit circle), so its square must be minimum phase too. Commented May 25 at 16:05
• @Hilmar: That's what I meant, they are marginally minimum-phase, but I'm usually happy with leaving out "marginally", because it's clear that for frequency selective filters we want zeros on the unit circle. In other words, there are no zeros outside the unit circle. You're right of course that these filters cannot be inverted. Commented May 25 at 16:08

The impulse response hmp is computed by convolving the impulse response of the elliptic filter with itself. We know that the elliptic filter is marginally minimum-phase, i.e., it has no zeros outside the unit circle. Convolving the impulse response with itself corresponds to squaring the transfer function. This doubles the multiplicity of all poles and zeros but it doesn't change their location. Hence, the impulse response hmp must also be marginally minimum-phase.

A more direct way to compute hmp would be

hmp = impz( conv(B,B), conv(A,A), Ns );

But note that hmp is of course only a finite length approximation of the ideal infinitely long impulse response. Even though it looks virtually identical to the ideal impulse response, its properties are different. Take as an example the pole-zero plot. The ideal impulse response has $$2N$$ poles and zeros (with $$N$$ being the order of the original elliptic filter). All poles have a radius greater than zero (and less than $$1$$), and all zeros lie on the unit circle. On the other hand, hmp has several thousand poles and zeros, and all its poles lie in the origin (because it is a causal FIR filter).

A filter is minimum phase when all it's poles and zeros are inside the unit circle. The easiest way to check is to inspect the zeros and poles of the filter and look at the magnitudes

>> [z,p,k] = ellip(N, Rp, Rs, Fp/(0.5*Fs)); % Matlab
[abs(z) abs(p)]
ans =
1      0.57824
1      0.57824
1      0.79834
1      0.79834
1      0.92616
1      0.92616
1      0.98198
1      0.98198


Here we run into an issue. The poles are all safely inside the unit but the zeros are directly on it, so the filter is NOT strictly minimum phase, at least not per the author's own explicit definition.

This being said, the filter has minimum phase time domain properties (its causal and the energy is front loaded). However it's NOT invertible.

So the point that the author is trying to make still stands: minimum (or sort of minimum) phase filters in audio are often preferable to linear phase filters.