.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_2_2_2_heisenberg_gabor_inequality.py: ========================== Heisenbeg-Gabor Inequality ========================== This example demonstrates the `Heisenberg-Gabor inequality `_. Simply put, the inequality states that the time-bandwidth product of a signal is lower bound by some constant (in this case normalized to unity). This means that a signal cannot have arbitrarily high precision in time and frequency simultaneously. Figure 2.2 from the tutorial. .. image:: /auto_examples/images/sphx_glr_plot_2_2_2_heisenberg_gabor_inequality_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Time Center: 126.99999999999999 Time Duration: 31.999999999999996 Frequency Center: 4.336808689942018e-19 Frequency Spreading: 0.03125 Time-bandwidth product: 0.9999999999999999 | .. code-block:: default from tftb.generators import amgauss from tftb.processing import loctime, locfreq import numpy as np import matplotlib.pyplot as plt # generate signal signal = amgauss(256) plt.subplot(211), plt.plot(np.real(signal)) plt.xlim(0, 256) plt.xlabel('Time') plt.ylabel('Real part') plt.title('Signal') plt.grid() fsig = np.fft.fftshift(np.abs(np.fft.fft(signal)) ** 2) plt.subplot(212), plt.plot(np.linspace(0, 0.5, 256), fsig) plt.xlabel('Normalized frequency') plt.ylabel('Squared modulus') plt.title('Spectrum') plt.grid() plt.subplots_adjust(hspace=0.5) plt.show() tm, T = loctime(signal) print("Time Center: {}".format(tm)) print("Time Duration: {}".format(T)) fm, B = locfreq(signal) print("Frequency Center: {}".format(fm)) print("Frequency Spreading: {}".format(B)) print("Time-bandwidth product: {}".format(T * B)) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.372 seconds) .. _sphx_glr_download_auto_examples_plot_2_2_2_heisenberg_gabor_inequality.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_2_2_2_heisenberg_gabor_inequality.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_2_2_2_heisenberg_gabor_inequality.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_