### Pre-requisites

Sampling theorem – baseband sampling

How to Interpret FFT results – complex DFT, frequency bins and FFTShift

## Related topic:

Analytic signal, Hilbert Transform and FFT

Extracting instantaneous amplitude,phase,frequency – application of Analytic signal/Hilbert transform

Phase demodulation using Hilbert transform – application of analytic signal

## 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

*and Ville*

**[1]***, aimed to create an*

**[2]***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*

**analytic signal***.*

**[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

*(imaginary part in the equation above)*

**find a companion function***such that the*

**to a real-valued signal****. Denoting Hilbert transform as \(HT\{\}\), the analytic signal is given by**

*real signal can be analytically extended from the real axis to the upper half of the complex plane*$$ 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*.

1 2 3 4 5 6 7 8 |
function z = analytic_signal(x) %x is a real-valued record of length N, where N is even %returns the analytic signal z[n] x = x(:); %serialize N = length(x); X = fft(x,N); z = ifft([X(1); 2*X(2:N/2); X(N/2+1); zeros(N/2-1,1)],N); end |

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.

1 2 3 4 5 6 7 8 9 10 11 |
t=0:0.001:0.5-0.001; x = sin(2*pi*10*t); %real-valued f = 10 Hz subplot(2,1,1); plot(t,x);%plot the original signal title('x[n] - original signal'); xlabel('n'); ylabel('x[n]'); z = analytic_signal(x); %construct analytic signal subplot(2,1,2); plot(t, real(z), 'k'); hold on; plot(t, imag(z), 'r'); title('Components of Analytic signal'); xlabel('n'); ylabel('z_r[n] and z_i[n]'); legend('Real(z[n])','Imag(z[n])'); |

## Python

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import numpy as np def main(): t = np.arange(start=0,stop=0.5,step=0.001) x = np.sin(2*np.pi*10*t) import matplotlib.pyplot as plt plt.subplot(2,1,1) plt.plot(t,x) plt.title('x[n] - original signal') plt.xlabel('n') plt.ylabel('x[n]') z = analytic_signal(x) plt.subplot(2,1,2) plt.plot(t,z.real,'k',label='Real(z[n])') plt.plot(t,z.imag,'r',label='Imag(z[n])') plt.title('Components of Analytic signal') plt.xlabel('n') plt.ylabel('z_r[n] and z_i[n]') plt.legend() def analytic_signal(x): from scipy.fftpack import fft,ifft N = len(x) X = fft(x,N) h = np.zeros(N) h[0] = 1 h[1:N//2] = 2*np.ones(N//2-1) h[N//2] = 1 Z = X*h z = ifft(Z,N) return z if __name__ == '__main__': main() |

## Hilbert Transform using FFT

We should note that the * hilbert* function in Matlab

*\(z[n]\)*

**returns the analytic 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.*

**not the hilbert transform of the signal**
1 |
x_hilbert = imag(analytic_signal(x)) |

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.

## References:

[1] D. Gabor, “Theory of communications”, Journal of the Inst. Electr. Eng., vol. 93, pt. 111, pp. 42-57, 1946. See definition of complex signal on p. 432.

[2] J. A. Ville, “Theorie et application de la notion du signal analytique”, Cables el Transmission, vol. 2, pp. 61-74, 1948.

[3] S. M. Kay, “Maximum entropy spectral estimation using the analytical signal”, IEEE transactions on Acoustics, Speech, and Signal Processing, vol. 26, pp. 467-469, October 1978.

[4] Frank R. Kschischang, “The Hilbert Transform”, University of Toronto, October 22, 2006

[5] S. L. Marple, “Computing the discrete-time ‘analytic’ signal via FFT,” Conference Record of the Thirty-First Asilomar Conference on Signals, Systems and Computers , Pacific Grove, CA, USA, 1997, pp. 1322-1325 vol.2.

Pingback: Phase demodulation using Hilbert transform – application of analytic signal – GaussianWaves()

Pingback: Extracting instantaneous amplitude,phase,frequency – application of Analytic signal/Hilbert transform – GaussianWaves()

Pingback: Choosing a filter – FIR or IIR – Understanding the design perspective – GaussianWaves()