# Phase and group delay

## Contents

# 10.4. Phase and group delay#

In the previous section, we saw how to investigate the properties of a convolutional filter \(\red{h}\) by examining its frequency response, that is, the magnitude of its DFT \(|\red{H}|\).
Examining the magnitude tells us an important part of the story, since it directly encapsulates the gain applied to each frequency when the filter is applied to a signal.
However, it’s not the entire story: **phase is also important**.

Recall that the convolution theorem converts time-domain convolution into frequency-domain multiplication:

Since each \(\red{H[m]}\) is a complex number, we can express it as \(\red{H[m]} = A \cdot e^{\mathrm{j}\phi}\) for magnitude \(A\) and phase \(\phi\). This tells us that the output DFT component \(\magenta{Y[m]}\) will be derived from \(\darkblue{X[m]}\) by scaling (multiply by \(A\)) and rotation by angle \(\phi\):

From the DFT shifting theorem, we know that applying delay to a signal results in a rotation of each DFT component \(\darkblue{X[m]}\), so we can interpret the rotation by \(\phi\) as implementing a delay of the \(m\)th sinusoid. The shifting theorem states precisely how this works: a delay of \(\red{k}\) samples induces a rotation of \(-2\pi\cdot \red{k \cdot m} / \blue{N}\) for frequency index \(\red{m}\) with signal length \(\blue{N}\), so that each frequency is rotated by an angle that depends on both the delay \(\red{k}\) and the frequency index \(\red{m}\).

However, there’s no guarantee that an arbitrary filter \(\red{H}\) will adhere to this structure. Depending on the phase structure of \(\red{H}\), the resulting signal could sound completely distorted. Analyzing the phase structure of \(\red{H}\) can reveal the presence of these distortions.

## 10.4.1. Examples#

Before going into analyzing filter phase, it will help to have some intuitive grasp of how important phase is to a signal.

The examples below demonstrate filters which do not affect the magnitude spectrum at all: \(|\magenta{Y[m]}| = |\darkblue{X[m]}|\), but the output signal \(\purple{y} = \red{h}*\blue{x}\) is substantially different from the input signal \(\blue{x}\).

(Discarding phase)

To demonstrate the importance of phase, we can listen to what happens when we discard all phase information in a signal, so that

This is equivalent to applying a filter with unit amplitude and phase exactly opposite of \(\darkblue{X[m]}\):

This can be implemented in Python as follows:

```
# Take the DFT
X = np.fft.rfft(x)
# Discard phase
Y = np.abs(X)
# Invert the DFT
y = np.fft.irfft(Y)
```

and the results are demonstrated below.

```
'Original signal: https://freesound.org/s/50712'
```