.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/communications/information/plot_01_nyquist_signalling_rate.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_communications_information_plot_01_nyquist_signalling_rate.py: Nyquist's signalling rate: 2B pulses per second =============================================== Harry Nyquist's "Certain topics in telegraph transmission theory" (1928) showed that a channel of bandwidth :math:`B` can carry at most :math:`2B` independent pulses per second without intersymbol interference (:func:`~engineeringkit.communications.nyquist_symbol_rate`). Sinc-shaped pulses spaced :math:`1/2B` apart are each zero at all the other sampling instants, so every pulse can be read without seeing its neighbours. Sending faster makes the pulses blur together. .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.communications import bpsk, nyquist_symbol_rate .. GENERATED FROM PYTHON SOURCE LINES 21-23 Sinc pulses at the Nyquist rate ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 23-51 .. code-block:: Python B = 1000.0 rate = float(nyquist_symbol_rate(B)) rng = np.random.default_rng(1928) symbols = bpsk(rng.integers(0, 2, 24)) t = np.linspace(-0.002, 0.014, 4001) def waveform(symbol_rate): T = 1 / symbol_rate return sum(a * np.sinc(2 * B * (t - k * T)) for k, a in enumerate(symbols)), np.arange(symbols.size) * T fig, axes = plt.subplots(2, 1, figsize=(8, 5), sharex=True) for ax, r in zip(axes, [rate, 1.5 * rate], strict=True): x, instants = waveform(r) samples = np.interp(instants, t, x) isi = np.max(np.abs(samples - symbols)[: int(0.012 * r)]) print(f"{r:6.0f} baud through B = {B:.0f} Hz: worst sampling error {isi:.3f}") ax.plot(t * 1e3, x) ax.plot(instants * 1e3, samples, "ko", ms=4) ax.set(xlim=(-1, 12), title=f"{r:.0f} baud ({r / rate:.1f} x Nyquist)") axes[-1].set_xlabel("time [ms]") fig.tight_layout() x, instants = waveform(rate) assert np.allclose(np.interp(instants[:20], t, x), symbols[:20], atol=5e-3) plt.show() .. image-sg:: /api/gallery/communications/information/images/sphx_glr_plot_01_nyquist_signalling_rate_001.png :alt: 2000 baud (1.0 x Nyquist), 3000 baud (1.5 x Nyquist) :srcset: /api/gallery/communications/information/images/sphx_glr_plot_01_nyquist_signalling_rate_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 2000 baud through B = 1000 Hz: worst sampling error 0.000 3000 baud through B = 1000 Hz: worst sampling error 1.793 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.162 seconds) .. _sphx_glr_download_api_gallery_communications_information_plot_01_nyquist_signalling_rate.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/communications/information/plot_01_nyquist_signalling_rate.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_nyquist_signalling_rate.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_nyquist_signalling_rate.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_nyquist_signalling_rate.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_