.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "glr_examples/utils/plot_savitzky_golay1d.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 Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_glr_examples_utils_plot_savitzky_golay1d.py: ================================================ Plot Savitzky Golay 1D filter ================================================ plot savitzky golay 1d from noise signal compared to filtered signal. .. GENERATED FROM PYTHON SOURCE LINES 8-11 .. code-block:: default # Author: L.Kouadio # Licence: BSD-3-clause .. GENERATED FROM PYTHON SOURCE LINES 12-13 Import required modules .. GENERATED FROM PYTHON SOURCE LINES 13-17 .. code-block:: default import numpy as np import matplotlib.pyplot as plt from watex.utils.exmath import savitzky_golay1d .. GENERATED FROM PYTHON SOURCE LINES 18-19 Generate signal for filtering and add Gaussian noises .. GENERATED FROM PYTHON SOURCE LINES 19-31 .. code-block:: default t = np.linspace(-3, 3, 500) y = np.exp( -t**2 ) + np.random.normal(0, 0.1, t.shape) # compute filtered signal ysg = savitzky_golay1d(y, window_size=45, order=3, mode ='valid') # plot noise signal vs filtered signal plt.figure(figsize =(10, 4)) plt.plot(t, y, label='Noisy signal') plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal') plt.plot(t, ysg, 'r', label='Filtered signal') plt.ylabel('precomputed signal') plt.xlabel ('signal bandwidth') plt.legend() plt.show() .. image-sg:: /glr_examples/utils/images/sphx_glr_plot_savitzky_golay1d_001.png :alt: plot savitzky golay1d :srcset: /glr_examples/utils/images/sphx_glr_plot_savitzky_golay1d_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.152 seconds) .. _sphx_glr_download_glr_examples_utils_plot_savitzky_golay1d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/watex/watex/0.2.X?urlpath=lab/tree/notebooks/glr_examples/utils/plot_savitzky_golay1d.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_savitzky_golay1d.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_savitzky_golay1d.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_