3
$\begingroup$

I can't find out if it possible to compute the minimum-phase response corresponding to a given magnitude response using a Hilbert transformer. Is that possible?

When I write Hilbert transformer I mean a 90-degree phase shifter.

I know other ways to compute the minimum-phase response but since there are IIR filters that approximately can realize a Hilbert transformer I was wondering if it is possible to use the Hilbert transformer. Not sure if the answer is obvious but it is not a homework question.

Edit:

Implementation of proposed

function y = test_minph(Mag)
    Mag  = Mag(:);
    x    = [Mag; Mag(end-1:-1:2)];
    len  = length(x);
    N    = (len)/2-1;
    wn   = [0; -1i*ones(N,1); 0; 1i*ones(N,1)];
    xhat = real(fft(log(x)));
    y    = -ifft(wn.*xhat);   
end

But the question is about how to compute the below using a Hilbert transformer (if possible) which is what robert johnson proposed.

function y = minphase(Mag)
    Mag  = Mag(:);
    x    = [Mag; Mag(end-1:-1:2)];
    len  = length(x);
    N    = (len)/2-1;
    wn   = [1; 2*ones(N,1) ; 1; zeros(N,1)];
    xhat = real(ifft(log(abs(x))));
    y    = imag(exp(fft(wn.*xhat)));
end

So it seems there are two different Hilbert transforms in play (don't know if they are dual) and I'm not sure how to compute the minimum-phase Hilbert transform using the 90 degree phase shift Hilbert transform. I hope it makes sense.

$\endgroup$
  • $\begingroup$ before i attempt an answer, i want to understand your question better. by "response", do you mean that you know the magnitude response of an LTI system or "filter" and, from that magnitude response, you want to calculate a phase response that would be the minimum-phase response? $\endgroup$ – robert bristow-johnson Aug 5 '17 at 22:42
  • $\begingroup$ @robertbristow-johnson Exactly. As you probably already are aware of then for a minimum-phase system (LTI) the phase can be fully recovered from the magnitude response. I have been looking for an IIR filter solution and thought that I could use a hilbert transformer because they are built on similar principles such as causality and one-sideness. But after looking for closely I don't immediately see how I can use a Hilbert transformer. $\endgroup$ – greggo Aug 6 '17 at 18:19
  • $\begingroup$ You can't directly use a pair of IIR all-pass filters the outputs of which have a 90 deg phase difference. Instead, consider those outputs as the real and imaginary parts of a complex signal, equivalent to using a complex filter that attenuates negative frequencies. Do forward-backward filtering using the complex filter. (JOS writes: "If the filter were complex, then we would need to conjugate its coefficients when running it backwards.") The imaginary part of the final output is the Hilbert transform of the original input. $\endgroup$ – Olli Niemitalo Aug 7 '17 at 10:17
  • $\begingroup$ Like so: Martin Vicanek, A New Reverse IIR Filtering Algorithm, 25. October 2015. $\endgroup$ – Olli Niemitalo Aug 7 '17 at 10:28
  • $\begingroup$ @OlliNiemitalo I'm sorry, I will try to update the question if I can find a way to make more clear what I'm asking. I think there is some confusion here about the difference between a hilbert transformer and the hilbert transform providing minimum-phase. Maybe, I'm the only one confused here but I don't think they are the same. At some level my question is about the relation between those two instead of how to realize a hilbert transformer (90 degree phase shifter)...which is also interesting and very likely I will ask about that in another question. $\endgroup$ – greggo Aug 7 '17 at 10:56
4
$\begingroup$

as a related aside question i posted this question about minimum-phase filters and the phase-magnitude relationship.

let $N$ be the FFT size you will use. (often $N$ is a power of two, but it doesn't have to be.)

the target magnitude response is

$$ G[k] \qquad \text{for } 0 \le k \le \tfrac{N}{2} $$

$G[0]$ is the magnitude at DC. $G[\tfrac{N}2]$ (if $N$ is even) is the magnitude at Nyquist. $G[k]$ must be purely real and positive. No complex values and no polarity (sign) changes. Then, when converting to log-magnitude, the logarithm function should not give you trouble.

First thing is convert magnitude to nepers using the natural (base-$e$) logarithm.

$$ H[k] = \ln(G[k]) \qquad 0 \le k \le \tfrac{N}2 $$

If you started with gain in dB, it has already been logged. but dB are not nepers. you must multiply each value by $\frac{1}{20}\ln(10)$ = 0.115129255 (that's one of these magic numbers we get to see in DSP).

you need not worry about any constant added to the log-magnitude (which would correspond to a positive gain factor in $G[k]$). the Hilbert transform of a constant is zero so the minimum-phase result will be unchanged no matter how $G[k]$ is scaled.

You must mirror the first half into the latter half (the latter half of the DFT corresponds to negative frequencies or negative times):

$$ H[k] = H[N-k] \qquad \tfrac{N}2 < k \le N-1 $$

Then, to compute the Hilbert transform, there are 3 steps. First, compute

$$\begin{align} h[n] &= \mathcal{DFT}\bigg\{ H[k] \bigg\} \\ \\ &= \sum\limits_{k=0}^{N-1} H[k] e^{-j 2 \pi \frac{nk}N} \\ \end{align}$$

Then, multiply every positive time index ($n<\tfrac{N}2$) with $-j = e^{-j\frac\pi2}$ (or spin those complex values by -90°) and multiply every negative time index ($n>\tfrac{N}2$) with $+j = e^{+j\frac\pi2}$ (or spin those complex values by +90°). $h[0]$ and $h[\tfrac{N}2]$ (if $N$ is even) should be set to 0.

$$ h[n] \leftarrow \begin{cases} 0 & n=0 \\ -j \cdot h[n] \qquad & 1 \le n< \tfrac{N}2 \\ 0 & n=\tfrac{N}2 \\ j \cdot h[n] \qquad & \tfrac{N}2 < n \le N-1 \\ \end{cases} $$

Finally inverse transform that result (and negate)

$$\begin{align} \phi[k] &= -\mathcal{IDFT}\bigg\{ h[n] \bigg\} \\ \\ &= - \tfrac1N \sum\limits_{n=0}^{N-1} h[n] e^{j 2 \pi \frac{nk}N} \\ \end{align}$$

$\phi[k]$ is the phase, in radians, of the minimum-phase system. Your complex transfer function is

$$ G[k] \, e^{j \phi[k]} $$.

$\endgroup$
  • $\begingroup$ Thanks! Unfortunately I can't vote yet. I'm not sure I follow your answer. If I understand correctly your answer is saying that if the log-magnitude is phase shifted 90 degrees that will provide the minimum-phase. I'm not sure that is correct. Experimentally I can't make sense of it. I think your description will provide an analytic signal which I don't think is equal to the minimum-phase. But I'm not very confident in this. $\endgroup$ – greggo Aug 7 '17 at 8:24
  • $\begingroup$ the phase response (phase measured in radians) of a minimum-phase system is the negative of the Hilbert transform of the log-magnitude response (where the log-magnitude is in nepers). to compute the Hilbert transform, you DFT, multiply the first half of the DFT bins with $-j$ and the latter half (which corresponds to negative frequencies) with $+j$, and then inverse DFT. $\endgroup$ – robert bristow-johnson Aug 7 '17 at 18:47
  • $\begingroup$ The Hilbert transform you outline gives you the analytic signal not the minimum-phase, I think. If you test the code I have edited into the question you can see your (90 degree phase shifter) does not give the minimum-phase. $\endgroup$ – greggo Aug 7 '17 at 18:52
  • $\begingroup$ no, greggo. it's not the analytic signal. $\endgroup$ – robert bristow-johnson Aug 7 '17 at 18:54
  • $\begingroup$ and it's not the minimum-phase signal, so what is it? My interpretation of p. 789 (eq. 11.58) in Oppenheim and Schafer second edition is that it is the analytic signal. $\endgroup$ – greggo Aug 7 '17 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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