What is an efficient and accurate Mathematica implementation of the Hilbert transform, for both continuous and especially discretely sampled functions?
This transform relates phase and amplitude in minimum phase systems.
|
What is an efficient and accurate Mathematica implementation of the Hilbert transform, for both continuous and especially discretely sampled functions? This transform relates phase and amplitude in minimum phase systems. |
||||
|
For continuous signal, I think is easy, took this in a course. For discrete, hard for me, we did not study it at school (yet). But if the signal is continuous, this gives the Hilbert transform of the signal:
==>
P.S. I just saw a reference for the original paper for the implementation of discrete Hilbert transform. (link reference) by Kak, 1970. note(1) Just did a search on the net, and found what seems like a good reference with lots of Mathematica code for Hilbert transform, and a code for the discrete one. Reference is Handbook of geophysical exploration, volume 1 by Klaus Helbig and Sven Treitel. And on page 162, they give the implementation:
Here is a link to the on-line version I saw the above (link here) if you like to read more about it. note(2) I wrote the function from the book above to make it easy for others to use, here it is below, and put a quick Manipulate around it, used the triangle and square functions shown in the other answer here to make it to compare.
|
||||
|
|
Here's a direct implementation of the formula $$\mathcal H(u)(t) = \frac1{\pi} -\hspace{-1.1em}\int_{-\infty}^\infty \frac{u(\tau)}{t-\tau}\, \mathrm d\tau$$
Try it out:
For the discrete Hilbert transform, here is a Mathematica routine:
(making everything completely analogous to Examples:
|
||||
|
|
|
You can realize a discrete Hilbert transform by convolving your discrete signal with a Hilbert kernel. The convolution is implemented with least effort in the frequency domain, where the spectrum of the Hilbert kernel is $$\sigma_H(\omega)=-i\cdot\mathrm{sgn}(\omega)$$ where $\omega$ is the angular frequency. Continuous case We define a function to perform the convolution in the frequency domain for us
by exploiting the convolution theorem and getting the result back to our domain of interest via an inverse Fourier transform. In this case the Some results for the test cases from J.M.'s answer:
Discrete case In the discrete case we prepare the phase shifts for the occurring frequencies for a given data size
which we can then use in
which, like its continuous counterpart, performs the convolution in frequency space. To reduce artifacts due to circular convolution in case of nonperiodic signals we can choose to pad the
this results in a good approximation of an inverted cosine:
But we can also try the transform on more interesting waveforms, for example a sine with continuously changing frequency
or a transition between different waveforms
|
|||||
|
graphtag on Stack Overflow, which is used for graphics/graph theory/facebook/etc. – rm -rf♦ Jan 20 '12 at 15:31