# How do I find the Hilbert transform (qudrature) of a discrete signal by convolution with a Hilbert kernel?

Given a discrete real signal $$f_{re}(t)$$ the (complex) analytic signal is given by:

$$x(t) = f_{re}(t) + j*f_{im}(t)$$.

I want to calculate $$f_{im}(t)$$: the quadrature by convolving with a Hilbert kernel of size 2*n+1:

$$f_{im}(t) = H*f_{re}(t)$$

$$H=[H_{-n},H_{-n+1},..,H_0,H_{n-1},H_n]$$

According to "Complex seismic trace analysis",M. T. Taner*, F. Koehler*, and R. E. Sheriff; $$H_i = 2*sin^2(\pi i/2)/(\pi i), H_0 = 0$$ for $$n = \infty$$.

I want to use a finite length kernel, e.g. n=16. Do I need to taper the kernel from the equation above with a window?

How do I normalize the odd (antisymmetric) result kernel?

Am I right in assuming that calculating the quadrature by convolving with H introduces a smoothing?

If so; should I also smooth the real signal, e.g. by a gaussian kernel of size 2n+1?

EDIT: In Matlab there is a function called "firpm" that creates a "Parks-McClellan optimal equiripple FIR filter".

It seems this is generally considered the "optimal" FIR approximation to an IIR?

Does this mean that using the simple coefficient equation from "Complex seismic trace analysis" is too simplistic?

EDIT2: regarding the normalization: I tested in Matlab and found that convolving with a kernel calculated from the simple coefficient equation gave good results in the case of the input signal being a sine. However I had to divide by a factor m to get correct normalization:

H5 = [-0.0000   -0.6366  0    0.6366    0.0000]: m = 0.1271
H7 = [-0.2122 -0.0000 -0.6366  0  0.6366 0.0000 0.2122]: m=0.2525


What is the general formulae for m?

EDIT 3: The ideal kernel would have constant magnitude response. However it seems that since my kernel will be of finite size; it will act as an bandpass filter, and therefore I need to look out for bandpass ripple. The solution seems to be a magnitude response that rolls of gently at the low and high frequencies. The "simple coefficient equation" is quite good in this respect; it does not introduce a lot of ripple, instead the shorter the kernel the earlier it starts rolling off. As an example here is the 19 point kernel: In comparison the 19 point kernel from Matlabs firpm does not roll of at high frequencies (!?) but otherwise have roughly the same amount of ripple as my simple kernel: My conclusion so far thus seem to be: no the "simple coefficient equation" gives a good approximation to the optimal FIR for the Hilbert convolution operator. The "Parks-McClellan optimal equiripple FIR filter" might be slightly more "optimal" but the difference is neglible, at least for reasonably large kernels (say 19 points and upwards). Anything I am forgetting? I will therefore move on with this approach. Only remaining problem: how do I normalize?

The short answer: with a finite convolution you can't calculate the Hilbert transform exactly.

The long answer: You will have to make approximations and decide what types and amounts of error you can live with. This will depend heavily on the application, the signals itself and what you are trying to do with the results. This paper may give good guidance on math and potential trade offs http://www.andrewduncan.ws/air/index.html

Per se, the Hilbert Transform is not a smoothing operation. For example the HT of a cosine is a sine, which isn't any smoother.

• Thanks Hilmar! I tend to think of convolution as smoothing. This is of course wrong as your example shows. I also remember that convolution can sharpen the signal for instance if the kernel is a "differentiator", e.g. [-1 0 1]. Am I right in assuming that symmetrical kernels are "smoothers" and asymmetrical are "sharpeners"?
– Andy
Mar 7, 2013 at 17:05
• "with a finite convolution you can't calculate the Hilbert transform exactly": generalizing; is this the difference between a FIR and a IIR? Regarding the "long answer": see my EDIT above.
– Andy
Mar 7, 2013 at 17:08
• The question stands though, how would you implement it as a convolution? What exactly are you convolving with? Mar 7, 2013 at 17:10
• The result of the convolution depends on what you convolve with. If it's a low pass filter it will smooth, if it's a high pass it will enhance transients. The hilbert is neither, it's an essence a phase shifter. You can only convolve with an FIR. IIR needs to be truncated for convolution. Mar 7, 2013 at 20:40

Here there is a nice implementation of a hilbert transformation applied onto a discreet signal.

https://stackoverflow.com/questions/10693590/source-for-a-good-simple-soft-modem-library

That codes starts by generating the hilbert transform in the frequency domain. To apply the hilbert transform to a sigal in the frequency space all you have to do is to multiply the negative frequencies by -j and the positives by j.

Then it uses the idft to convert the hilbert transform into the time domain. The hilbert transform, that in the frequency domanin is just a multiplication, in the time domain becomes a convolution. Note that in that implementation, in the frequency domain, the hiltbert transform has some of coefficients set to zero, it does that for the frequencies we are not interested in. That helps filter out those unwanted frequencies.