# Meaning of Phase response of a filter? In simple words?

What is meant by phase response of a filter? Often it is associated with restoration of signal shape,so if a filter has linear phase response, its output looks like input otherwise output is distorted if the filter has non linear phase response

Example of linear phase response filter is FIR filter and IIR filter is example of non linear phase response

But what is meant linear or non linear phase response? Please kindly explain in simple words preferably with an example containing figures or graphs for demonstration

## 6 Answers

There are many good answers here. I will try to take the reverse approach in order to explain in very simple words what is necessary in order to keep the output's shape same as input's, and what exactly distorts the shape.

You can keep this for intuition of Phase response not for exactness of mathematics.

Interpretation of Phase response : Negative of Derivative of phase response w.r.t. $$\omega$$ tells you as $$\omega$$ varies between $$[-\pi, \pi]$$, how is the different spectral component of input is getting delayed. If the phase response is linear, the derivative w.r.t. $$\omega$$ is constant and hence all spectral components of the input was just delayed by a constant amount. But if the phase response was non-linear, then different spectral component of the input will get delayed by a different amount and hence output gets distorted. Keep in mind that the delay happens in time-domain, but the phase response is in $$\omega$$-Domian.

Explanation through a simple example :

Suppose you want a filter which just delays the input $$x[n]$$ by $$n_o$$ samples. So, your output is basically $$y[n] = x[n-n_o]$$, where $$n_o$$ is an integer.

Since you have input-output relation, so, you can get the filter impulse response and filter frequency response easily.

The filter's frequency response will be :$$H(e^{j\omega}) = \frac{Y(e^{j\omega})}{X(e^{j\omega})} = \frac{DTFT(x[n-n_o])}{DTFT(x[n])},$$Apply time-shift property of DTFT, to get $$Y(e^{j\omega}) = X(e^{j\omega}).e^{-j\omega n_o}$$. So, $$H(e^{j\omega})$$ becomes the following: $$H(e^{j\omega}) = \frac{Y(e^{j\omega})}{X(e^{j\omega})} = \frac{X(e^{j\omega}).e^{-j\omega n_o}}{X(e^{j\omega})} = e^{-j\omega n_o}$$

This means that your filter was actually an all pass filter with magnitude response $$|H(e^{j\omega})| = 1, \forall \omega \in [-\pi, \pi]$$ and phase response is $$\angle{H(e^{j\omega})} = -n_o.\omega$$, that means it has linear phase response.So, the delay caused by this filter at different frequencies will be:$$delay(\omega) = -\frac{d(-n_o.\omega)}{d\omega} = n_o$$ And based on $$H(e^{j\omega})$$ it is clear that the impulse response of this filter is $$h[n] = \delta [n-n_o]$$.

Now, think what would have happened if the phase response was not linear, meaning if you could not take this factor $$e^{-j\omega n_o}$$ common while calculating the $$H(e^{j\omega})$$. That would have meant that for different frequencies $$\omega$$ in the frequency represenation of $$x[n]$$, the filter is causing a different delay. And, if this happens the shape of output will change.

For example, if for some filter $$H(e^{j\omega})$$ came out to be $$e^{-j\omega^2 m_o}$$. This is also having magnitude response as $$|H(e^{j\omega})| = 1$$, meaning no attenuation/gain of any spectral region. But the phase response is not linear, $$\angle{H(e^{j\omega})} = -m_o \omega^2$$, meaning delay caused by the filter at different frequencies will be given by: $$delay(\omega) = - \frac{d(-m_o \omega^2)}{d\omega} = m_o\omega,$$You see the delay becomes $$\omega$$ dependent and hence different spectral component is getting delayed by a different amount, which causes the distortion in shape of output even though magnitude response of the filter was $$1$$ for all frequencies.

• You are separately mentione filter impulse response and frequency response. But apparently both are same in the sense that both are ratio of output and input – Man Apr 20 '20 at 13:13
• @Man You are right, I meant time-domain $h[n]$ and freq-domain $H(e^{j\omega})$. – DSP Rookie Apr 20 '20 at 13:15
• You mean, impulse response h[n] is a time domain quantity? In frequency domain we don't have impulse response? – Man Apr 20 '20 at 15:02
• @Man we have impulse response in both time and Freq domain. It's just the way I wrote. Nothing serious about that. In fact what you mentioned in your first comment is absolutely correct. – DSP Rookie Apr 20 '20 at 15:06

Here is the same experiment done in my blog: https://poweidsplearningpath.blogspot.com/2020/04/chapter-51-meaning-of-general-linear.html

First, there is a tiny mistake in the question. Not all FIR filters have the properties of Linear Phase. Only the four types of FIR possess the properties. 1 By contrast, all of the IIR filters are not linear phases.

For me, one better description of general linear phase (GLP) is constant group delay. By definition, group delay is negative derivative of phase 2 (In fact, the detail phase/delay relationship can be derived but I suggest we just accept them.). Then, Derivative (group delay) of a linear (phase) is constant and vise versa.

Then, let's move on to the meaning of group delay. group delay of a frequency represents the delay unit of the filter to that frequency. So, the filter may treat different frequencies with different delay unit. For an extreme bad example of an non linear filter, the input signal 'do re mi' may becomes 're mi do' in the output. A GLP filter can guarantee that such wield condition will never happen.

Here I wrote an example. The example comes from the Chapter 5.1.2 in the bible of DSP3 and I just implemented the sample.

First, a IIR Filter with phase response like this is given. Fig. 1.

Here is the group delay (negative derivative of phase response) and the magnitude response. Please note that I delay the frequency in +-0.2 pi for about 150 units. BTW, the filter is a low pass filter so signal higher than 0.8pi is expected to be filtered. Fig. 2.

Then, let's input a test signal like 'do re mi'. The signal x[n] are '0.8pi, 0.2pi, 0.4pi' in order. The corresponding frequency response is also provided. Fig. 3.

And here is the output signal. The signal becomes 'empty, 0.4pi, 0.2pi'. The signal component with 0.8pi is filtered out as expected. Fig. 4.

To make thing more clear, here I points the number of Fig. 3 and Fig. 4 together. For 0.2pi component, the group delay is about 6.39 units but the group delay of 0.2pi component is about 153 unit. The output signal can confirm the prediction from group delay response. That is why the 0.2pi component becomes that last in the output. Fig. 5.

In summary,

1. linear phase equals to constant group delay.

2. GLP FIR filter can guarantee such scenario will never happen. But IIR can never achieve GLP. (But with the same mag frequency spectrm requirement, IIR usually can achieves the spec with lower delay (but not constant) in comparison with FIR.)

Reference:

1. FIR filter with linear phase, 4 types

2. https://en.wikipedia.org/wiki/Group_delay_and_phase_delay

3. A. Oppenheim and R. Schafer, Discrete Time Signal Processing 3rd. 2009

Matlab code

%% System
% H1[z]
b1 = conv([1 -.98*exp(j*.8*pi)],[1 -.98*exp(-j*.8*pi)]);
a1 = conv([1 -.8*exp(j*.4*pi)],[1 -.8*exp(-j*.4*pi)]);
H1 = tf(b1,a1,-1,'Variable','z^-1');

% H2[z]
H2 = tf(1,1,-1,'Variable','z^-1');
for k = 1:4
ck = 0.95*exp(j*(0.15*pi+0.02*pi*k));
ck_conj = conj(ck);
b_tmp = conv([ck_conj -1],[ck -1]);
b_tmp = conv(b_tmp,b_tmp);
a_tmp = conv([1 -1*ck],[1 -1*ck_conj]);
a_tmp = conv(a_tmp,a_tmp);
H_tmp = tf(b_tmp,a_tmp,-1,'Variable','z^-1');

H2 = series(H2,H_tmp);
end

% H[z]
H = series(H1,H2);

% Zero-Pole Plot, Fig. 5.2
[b_h,a_h] = tfdata(H );
b_h = cell2mat(b_h);
a_h = cell2mat(a_h);

figure;
zplane(b_h,a_h);
suptitle('Zero-Pole Plot, Fig 5.2');

% System Response.
L=1000;
dw=2*pi/L;
w = -pi:dw:pi-dw;
HH=freqz(b_h,a_h,w);
mag=abs(HH);
phase=angle(HH);

% Fig. 5.3
figure;
subplot(2,1,1);
plot(w,phase);
xticks([-pi -0.8*pi -0.6*pi -0.4*pi -0.2*pi 0 0.2*pi 0.4*pi 0.6*pi 0.8*pi pi]);
xticklabels({'-\pi','-0.8\pi','-0.6\pi','-0.4\pi','-0.2\pi','0','0.2\pi','0.4\pi','0.6\pi','0.8\pi','\pi'});
xlim([-pi pi]);
yticks([-4 -2 -0 2 4]);
ylabel('ARG[H(e^(^j^w^)]');
xlabel('w');
title('Phase response');

subplot(2,1,2);
plot(w,unwrap(phase));
xticks([-pi -0.8*pi -0.6*pi -0.4*pi -0.2*pi 0 0.2*pi 0.4*pi 0.6*pi 0.8*pi pi]);
xticklabels({'-\pi','-0.8\pi','-0.6\pi','-0.4\pi','-0.2\pi','0','0.2\pi','0.4\pi','0.6\pi','0.8\pi','\pi'});
xlim([-pi pi]);
ylabel('arg[H(e^(^j^w^)]');
xlabel('w');
title('Unwrap Phase response');
suptitle('ARG/arg Plot, Fig 5.3');

% Fig. 5.4
figure;
subplot(2,1,1);
plot(w(1:end-1),-1*diff(unwrap(phase))./diff(w));
xticks([-pi -0.8*pi -0.6*pi -0.4*pi -0.2*pi 0 0.2*pi 0.4*pi 0.6*pi 0.8*pi pi]);
xticklabels({'-\pi','-0.8\pi','-0.6\pi','-0.4\pi','-0.2\pi','0','0.2\pi','0.4\pi','0.6\pi','0.8\pi','\pi'});
xlim([-pi pi]);
ylabel('grd[H(e^(^j^w^)]');
title('Group Delay');

subplot(2,1,2);
plot(w,mag);
xticks([-pi -0.8*pi -0.6*pi -0.4*pi -0.2*pi 0 0.2*pi 0.4*pi 0.6*pi 0.8*pi pi]);
xticklabels({'-\pi','-0.8\pi','-0.6\pi','-0.4\pi','-0.2\pi','0','0.2\pi','0.4\pi','0.6\pi','0.8\pi','\pi'});
xlim([-pi pi]);
ylabel('|H(e^(^j^w^)|');
title('Magnitude response');
suptitle('GD/mag Plot, Fig 5.4');

%% Signal
M = 60;
n = 0:M;
w = 0.54-0.46*cos(2*pi*n/M);

N = 512;
x1 = zeros(1,N);
x2 = zeros(1,N);
x3 = zeros(1,N);
dw = 2*pi/N;
w_freq = -pi:dw:pi-dw;

for i = 0:M

x1(i+M) = w(i+1)*cos(0.2*pi*i);
x2(i+2*M-1) = w(i+1)*cos(0.4*pi*i-pi/2);
x3(i+1) = w(i+1)*cos(0.8*pi*i+pi/5);
end
x = x1+x2+x3;
X = abs(fft(x));
X = fftshift(X);

% Fig. 5.5
figure;
subplot(2,1,1);
plot(x);
title('x[n]');
xlim([0,300]);
subplot(2,1,2);
plot(w_freq,X);
xticks([-pi -0.8*pi -0.6*pi -0.4*pi -0.2*pi 0 0.2*pi 0.4*pi 0.6*pi 0.8*pi pi]);
xticklabels({'-\pi','-0.8\pi','-0.6\pi','-0.4\pi','-0.2\pi','0','0.2\pi','0.4\pi','0.6\pi','0.8\pi','\pi'});
xlim([-pi pi]);
ylabel('|H(e^(^j^w^)|');
title('DTFT of X');
suptitle('Input time/Freq., Fig 5.5');

%% Output
y = filter(b_h,a_h,x);

% Fig. 5.6
figure;
plot(y);
xlim([0,300]);
xlabel('n');
title('output y[n], Fig 5.6');

%= Compre the Delay sample point.
figure;
subplot(2,1,1);
plot(x);
xlim([0,300]);
xlabel('n');
ylabel('x[n]');
title('input');
subplot(2,1,2);
plot(y);
xlim([0,300]);
xlabel('n');
ylabel('y[n]');
title('output');


Linear phase simply means that all the frequencies in the signal are delayed by a constant amount, this means no distortion.

Non linear phase means that the group delay is not constant for all frequencies. So different frequencies are delayed or advanced by different number of samples in time. This would clearly mean distortion of the original signal.

For a good graphical explanation of non linear phase and group delay have a look at this recent question.

Negative group delay and envelope advance

The phase response is simply the phase angle you would get between the output and input for a tone at a given frequency $$\omega$$. Like the magnitude response it is therefore a function of frequency as each frequency can result in a different phase shift, so the result is $$\phi(\omega)$$.

This post should now make more sense about what linear phase is and why it is important: Why is a linear phase important?

For more details on Linear Phase filters and the derivation for why the phase is linear see Linear-Phase FIR filters

Explaining further requires an understanding of complex numbers and frequency represented as $$e^{j\omega t}$$; A better answer starts with getting that, but not sure if that was beyond "simple words". Dealing with frequencies as only sines or cosines leads to the common misconception that a phase shift between two signals implies one is later than the other in time but that is not the case. Phase is a rotation given by $$e^{j(\omega t+\phi)}$$. A fixed delay in time leads to frequency dependent phase that in linearly changing over frequency, hence linear phase.

You've probably seen the standard decomposition of a square wave into a sine wave plus a bunch of odd harmonic sine waves.

If you delay the fundamental frequency sine wave by one period, and each Nth harmonic by N periods of that harmonic, the resulting square wave will look the same. That is a linear delay, because the delay is a constant linear multiple of each harmonic's frequency.

Change the delay of some harmonic to some fraction of a period, instead of a integer multiple, and the square wave will be distorted. This is what commonly happens with a non-linear phase response.

Phase Response of a filter shows how the filter affects the phase of the input as the signal passes through the filter. For an LTI system, $$Y(e^{j\omega}) = H(e^{j\omega})X(e^{j\omega})$$, whether frequency response of filter can be written as $$|H(e^{j\omega})|e^{j\phi(\omega)}$$. The phase response is $$\phi(\omega)$$.

For a simple delay filter $$h[n] = \delta[n-k]$$, $$H(e^{j\omega})=e^{-j\omega k}$$. So, $$\phi(\omega) = -\omega k$$ which is a linear phase response. The envelope of the input signal is preserved as the group delay ($$\frac{-d\phi}{d\omega}$$) is constant = $$k$$. All frequencies have equal delay of $$k$$ so output will maintain the same envelope as input.

An FIR need not be linear phase always. It just happens that the coefficients of FIR filter can easily be chosen such that $$\phi(\omega)$$ is linear. For example, $$h[n]=\{1,2,3,2,1\}$$ has linear phase response as shown below. The group delay $$\frac{-d\phi}{d\omega}$$ is constant. If we alter the coefficients of $$h[n]$$ say $$h[n]=\{1,3,3,2,1\}$$, the linear phase property is disturbed. That is group delay $$\frac{-d\phi}{d\omega}$$ is not a constant. Few frequencies arrive late with a different delay than another few set of frequencies. Few frequencies arrive early (though it is physically impossible for output to arrive earlier than input, the recent QA Negative group delay and envelope advance has a dealt this topic well). 