1
$\begingroup$

Consider the Discrete Hilbert Transform, which takes a sequence $u[n]$ defined on the interval $-M\leq n\leq M$ and returns the discrete convolution

$$\tilde u[n]=\sum_{i=-M}^Mu[i]h[n-i]$$

where the impulse response function is given by

$$ h[n] = \begin{cases} \frac{1}{\pi n}\big(1 - (-1)^n \big) \quad & n \in \mathbb{Z}, \ n \ne 0 \\ \\ 0 & n = 0 \\ \end{cases}$$

The wikipedia article above mentions an improved version of the discrete impulse response function:

$$h_N[n]=\sum_{m=-\infty}^\infty h[n-m N]$$

which exhibits a milder frequency cut-off, such that the finite $M$ impulse response is closer to the ideal infinite impulse response $M\to\infty$.

Now my question is:

Are there any other useful variations of $h[j]$ that would improve the discrete Hilbert transform spectrum and accuracy?

Or perhaps there are some entirely different ways to improve the finite impulse response of a discrete Hilbert transform? Thanks for any suggestion!

$\endgroup$

2 Answers 2

2
$\begingroup$

Try multiplying your $h[n]$ with a Kaiser window.

$$ h[n] = \frac{1}{\pi n} \big(1 - (-1)^n \big) \ w[n] $$

where the window function is

$$ w[n] = \begin{cases} \frac{1}{I_0(\beta)} \, I_0\left(\beta \sqrt{1 - \left(\frac{n}{M}\right)^2 } \right) \qquad & |n| \le M \\ 0 & |n| > M \\ \end{cases}$$

and

$$ I_0(u) \triangleq \sum\limits_{k=0}^{\infty} \frac{(-1)^k \big( \tfrac{u}{2} \big)^{2k}}{(k!)^2} $$

is the zeroth-order Bessel function of the first kind. with the Kaiser window, knowing the length $2M+1$ ($M$ might be 16 samples, or 32 if you want it really good) you can choose $\beta$ to tradeoff between the stopband attenuation and transition bandwidth of the reconstruction brickwall filter. a good value of $\beta$ is 6 or 7, to get you about 63 dB or 72 dB of stopband attenuation.

$\endgroup$
1
$\begingroup$

Yes a simple and effective way to improve the impulse response of the perfect Discrete Hilbert Transform, given by:

$$h[n] = \frac{1 - (-1)^n}{\pi n}$$

Is to multiply it with a window (after is has been delayed to meet causality requirements and truncated to a fixed length). Below shows the result of using a Kaiser window for a 91 sample response in blue, compared to not using any window in orange. (With no phase error from true quadrature across all frequencies).

Kaiser Windowed Impulse Response

The frequency response is the DTFT of the impulse response, and samples of the DTFT are returned by the freqz command in MATLAB, Octave and Python scipy.signal. Equivalently as another approach, a zero padded FFT will provide samples of the DTFT so can be used to provide a similar magnitude response. In time domain:

enter image description here

Below is the Python code that generates the above plots:

import numpy as np
import scipy.signal as sig
import matplotlib.pyplot as plt

ntaps = 91
# generate ideal impulse response
n = np.arange(-(ntaps-1)/2, (ntaps-1)/2+1)
hn = 2/(np.pi*n)   # will get a divide by zero warning
hn[1::2]=0

# Window
win = sig.kaiser(ntaps, 6)
coeff = hn*win

# Plot DTFT
w, h = sig.freqz(coeff)
w, h2 = sig.freqz(hn)
plt.figure()
plt.plot(w, 20*np.log10(np.abs(h)))   # windowed 
plt.plot(w, 20*np.log10(np.abs(h2)))  # non-windowed 

# Plot in time domain
def plotscat(x, y, title, ax):
    ax.plot(x, y)
    ax.scatter(x, y, s=20)
    ax.set_title(title, fontsize=18)
    ax.set_xlabel("n", fontsize=18)
    ax.tick_params(labelsize=13)

fig, axes = plt.subplots(1, 2, sharey=True)
plotscat(n, hn, 'h[n] = "Ideal" impulse response', axes[0])
plotscat(n, coeff, "Windowed h[n]", axes[1])
fig.subplots_adjust(wspace=.025, left=.05, right=.95)

Other approaches based using optimized filter design can improve this much further, for example the above solution has an amplitude error less than 0.012 dB with perfect quadrature and over 90% frequency coverage; below demonstrates amplitude errors less than 0.005 dB with perfect quadrature and over 90% frequency coverage using the same number of coefficients. Two approaches are shown below were based on designing optimized prototype half-band filters using least squares and window design approaches (with similar results) and frequency translating the filters by $\omega = \pi/2$.

optimized Hilbert design

$\endgroup$
3
  • $\begingroup$ "Magnitude response" is DFT of $h[n]$, or sampling of CFT of brickwalled $h[n]$? If it's DFT, what's the negative spectrum look like? $\endgroup$ Oct 8, 2022 at 21:56
  • $\begingroup$ @OverLordGoldDragon magnitude response is the DTFT (a continuous function in frequency)for the discrete time Hilbert Impulse response, not DFT. h[n] is real so frequency response is Hermitian symmetric (negative frequencies are the complex conjugate of the positive frequencies with same magnitude)- in this case as b goes to infinity magnitude is 1 everywhere but DC and Nyquist and phase is -j for positive freq and +j for neg freq. $\endgroup$ Oct 8, 2022 at 23:56
  • $\begingroup$ Related: dsprelated.com/freebooks/sasp/… $\endgroup$
    – Ash
    Oct 9, 2022 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.