# Analytic signal, Hilbert Transform and FFT

(4 votes, average: 4.75 out of 5)

## Introduction

Fourier Transform of a real-valued signal is complex-symmetric. It implies that the content at negative frequencies are redundant with respect to the positive frequencies. In their works, Gabor [1] and Ville [2], aimed to create an analytic signal by removing redundant negative frequency content resulting from the Fourier transform. The analytic signal is complex-valued but its spectrum will be one-sided (only positive frequencies) that preserved the spectral content of the original real-valued signal. Using an analytic signal instead of the original real-valued signal, has proven to be useful in many signal processing applications. For example, in spectral analysis, use of analytic signal in-lieu of the original real-valued signal mitigates estimation biases and eliminates cross-term artifacts due to negative and positive frequency components [3].

## Continuous-time analytic signal

Let $$x(t)$$ be a real-valued non-bandlimited finite energy signal, for which we wish to construct a corresponding analytic signal $$z(t)$$.  The Continuous Time Fourier Transform of $$x(t)$$ is given by

$$X(f) = \int_{-\infty}^{\infty} x(t) e^{-j 2 \pi f t} dt \;\;\;\;\; (1)$$

Lets say the magnitude spectrum of $$X(f)$$ is as shown in Figure 1(a). We note that the signal $$x(t)$$ is a real-valued and its magnitude spectrum $$|X(f)|$$ is symmetric and extends infinitely in the frequency domain.

As mentioned in the introduction, an analytic signal can be formed by suppressing the negative frequency contents of the Fourier Transform of the real-valued signal. That is, in frequency domain, the spectral content $$Z(f)$$ of the analytic signal $$z(t)$$ is given by

$$Z(f) = \begin{cases} \;X(0) & for \; f=0 \\2X(f) & for \; f>0 \\ \;\;\;0 & for \; f<0 \end{cases} \;\;\;\;\; (2)$$

The corresponding spectrum of the resulting analytic signal is shown in Figure 1(b).

Since the spectrum of the analytic signal is one-sided, the analytic signal will be complex valued in the time domain, hence the analytic signal can be represented in terms of real and imaginary components as $$z(t) = z_r(t) + j z_i(t)$$. Since the spectral content is preserved in an analytic signal, it turns out that the real part of the analytic signal in time domain is essentially the orginal real-valued signal itself $$(z_r(t) = x(t))$$. Then, what takes place of the imaginary part ? Who is the companion to x(t) that occupies the imaginary part in the resulting analytic signal ? Summarizing as equation,

$$\begin{gather} \;\;\;\;\;\;\;\;\;\;\;\;\;\;\; z(t) = z_r(t) + j z_i(t) \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;(3) \\ z_r(t) = x(t) \;\;\;\;\; z_i(t) = \; ?? \end{gather}$$

It is interesting to note that Hilbert transform [4] can be used to find a companion function (imaginary part in the equation above) to a real-valued signal such that the real signal can be analytically extended from the real axis to the upper half of the complex plane . Denoting Hilbert transform as $$HT\{\}$$, the analytic signal is given by

$$z(t) = z_r(t) + j z_i(t) = x(t) + j HT\{x(t)\} \;\;\;\;\; (4)$$

From these discussion, we can see that an analytic signal $$z(t)$$ for a real-valued signal $$x(t)$$, can be constructed using two approaches.

• Frequency domain approach: The one-sided spectrum of $$z(t)$$ is formed from the two-sided spectrum of the real-valued signal $$x(t)$$  by applying equation (2)
• Time domain approach: Using Hilbert transform approach given in equation (4)

One of the important property of an analytic signal is that its real and imaginary components are orthogonal

$$\int_{-\infty}^{\infty} z_i(t) z_r(t) = 0 \;\;\;\;\; (5)$$

## Discrete-time analytic signal

Since we are in digital era, we are more interested in discrete-time signal processing. Consider a continuous real-valued signal $$x(t)$$ gets sampled at interval $$T$$ seconds and results in $$N$$ real-valued discrete samples $$x[n]$$, i.e, $$x[n] = x(nT)$$. The spectrum of the continuous signal is shown in Figure 2(a). The spectrum of $$x[n]$$ that results from the process of periodic sampling is given in Figure 2(b) (Refer here more details on the process of sampling).  The spectrum of discrete-time signal $$x[n]$$ can be obtained by Discrete-Time Fourier Transform (DTFT).

$$X(f) = T \sum_{n=0}^{N-1} x[n] e^{-j 2 \pi f n T} \;\;\;\;\; (6)$$

At this point, we would like to construct a discrete-time analytic signal $$z[n]$$ from the real-valued sampled signal $$x[n]$$. We wish the analytic signal is complex valued $$z[n] = z_r[n] + j z_i[n]$$ and should satisfy the following two desired properties

• The real part of the analytic signal should be same as the original real-valued signal.
$$z_r[n] = x[n]$$
• The real and imaginary part of the analytic signal should satisfy the property of orthogonality
$$\sum_{0}^{N-1} z_r[n] z_i[n] = 0$$

In Frequency domain approach for the continuous-time case, we saw that an analytic signal is constructed  by suppressing the negative frequency components from the spectrum of the real signal. We cannot do this for our periodically sampled signal $$x[n]$$. Periodic mirroring nature of the spectrum prevents one from suppressing the negative components. If we do so, it will vanish the entire spectrum. One solution to this problem is to set the negative half of each spectral period to zero. The resulting spectrum of the analytic signal is shown in Figure 2(c).

Given a record of samples $$x[n]$$ of even length $$N$$, the procedure to construct the analytic signal $$z[n]$$ is as follows. This method satisfies both the desired properties listed above.

• Compute the $$N$$-point DTFT of $$x[n]$$ using FFT
• N-point periodic one-sided analytic signal is computed by the following transform
$$Z[m] = \begin{cases} \;\;X[0] & for \; m=0 \\ 2X[m] & for \; 1 \leq m \leq \frac{N}{2}-1 \;\;\;\;\;\; (7) \\ \;X[\frac{N}{2}] & for \; m = \frac{N}{2}\\ \;\;\;0 & for \; \frac{N}{2}+1 \leq m \leq N-1 \\ \end{cases}$$
• Finally, the analytic signal $$z[n]$$ is obtained by taking the inverse DTFT of $$Z[m]$$
$$z[n] = \frac{1}{NT} \sum_{m=0}^{N-1} z[m] \; exp \left( j 2 \pi mn/N\right)$$

## Matlab

The given procedure can be coded in Matlab using the FFT function. Given a record of $$N$$ real-valued samples $$x[n]$$, the corresponding analytic signal $$z[n]$$ can be constructed as given next. Note that the Matlab has an inbuilt function to compute the analytic signal. The in-built function is called hilbert.

To test this function, we create a 5 seconds record of a real-valued sine signal. The analytic signal is constructed and the orthogonal components are plotted in Figure 3. From the plot, we can see that the real part of the analytic signal is exactly same as the original signal (which is the cosine signal) and the imaginary part of the analytic signal is $$-90 ^\circ$$ phase shifted version of the original signal. We note that the imaginary part of the analytic signal is a cosine function with amplitude scaled by $$-1$$ which is none other than the Hilbert transform of sine function.

## Python

Equivalent code in Python is given below (tested with Python 3.6.0)

## Hilbert Transform using FFT

We should note that the hilbert function in Matlab returns the analytic signal $$z[n]$$ not the hilbert transform of the signal $$x[n]$$. To get the hilbert transform, we should simply get the imaginary part of the analytic signal. Since we have written our own function to compute the analytic signal, getting the hilbert transform of a real-valued signal goes like this.

In the coming posts, we will some of the applications of constructing an analytic signal. For example: Find the instantaneous amplitude and phase of a signal, envelope detector for an amplitude modulated signal, detecting phase changes in a sine wave.

(4 votes, average: 4.75 out of 5)