1
$\begingroup$

If I numerically compute the envelope of $\sin(\pi t)$ using a Hilbert transform, I obtain exactly what I expect:

enter image description here

If I do the same for $\mathrm{sinc}(t)$, still I obtain an envelope which agrees with my intuitions:

enter image description here

However, if I try to find the envelope of a Gibbs oscillation using the Fourier series for the Heaviside $\theta$ function, I obtain the following very wild figure which does not agree with my intuitions about what an envelope should look like:

enter image description here

Are there techniques for computing the envelope of Gibbs oscillations? I have tried a Kaiser window on the times series before computing the Hilbert transform, but no joy.

Code to reproduce:

#!/usr/bin/env python3
from math import pi as π
import random
import scipy
import numpy

import matplotlib
import matplotlib.pyplot as plt

def sine_envelope():
    times = numpy.linspace(-1, 1, 512)
    values = numpy.sin(π*times)
    analytic_signal = scipy.signal.hilbert(values)
    hilbert_transform = numpy.imag(analytic_signal)
    plt.plot(times, values, color="orange", label="Signal")
    plt.plot(times, hilbert_transform, color="green", label="Hilbert transform")
    plt.plot(times, numpy.abs(analytic_signal), color="steelblue", label="Envelope")
    plt.legend()
    plt.tight_layout()
    plt.show()

def sinc_envelope():
    times = numpy.linspace(-1, 1, 512)
    values = numpy.sinc(π*times)
    analytic_signal = scipy.signal.hilbert(values)
    hilbert_transform = numpy.imag(analytic_signal)
    plt.plot(times, values, color="orange", label="Signal")
    plt.plot(times, hilbert_transform, color="green", label="Hilbert transform")
    plt.plot(times, numpy.abs(analytic_signal), color="steelblue", label="Envelope")
    plt.legend()
    plt.tight_layout()
    plt.show()

def gibbs_oscillation_envelope():
    times = numpy.linspace(-1, 1, 512)
    values = numpy.zeros(len(times))
    for n in range(20):
        m = 2*n+1
        bm = 2/(m*π)
        values += bm*numpy.sin(2*π*m*times/10)

    analytic_signal = scipy.signal.hilbert(values)
    hilbert_transform = numpy.imag(analytic_signal)
    plt.plot(times, values, color="orange", label="Signal")
    plt.plot(times, hilbert_transform, color="green", label="Hilbert transform")
    plt.plot(times, numpy.abs(analytic_signal), color="steelblue", label="Envelope")
    plt.legend()
    plt.tight_layout()
    plt.show()




if __name__ == '__main__':
    sine_envelope()
    sinc_envelope()
    gibbs_oscillation_envelope()

$\endgroup$
1

1 Answer 1

1
$\begingroup$

The reason seems Hilbert transform works the best for signals like $x(t)=a\cos(\phi(t))$, where $a$ may change mildly. In your last case, this $a$ is not in this scenario.

You can try to apply your code to this

 values = numpy.zeros(len(times)) + 2

which simply shifts the whole function, but it should generate better result.

$\endgroup$

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.