
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/signals/plot_univariate_polynomial.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_signals_plot_univariate_polynomial.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_signals_plot_univariate_polynomial.py:


=====================
Univariate Polynomial
=====================

We will generate three univariate polynomials of a given time series. The order of the
polynomials will be 1, 2 and 3, respectively.

.. GENERATED FROM PYTHON SOURCE LINES 11-85



.. image-sg:: /auto_examples/signals/images/sphx_glr_plot_univariate_polynomial_001.png
   :alt: Univariate Polynomial 
   :srcset: /auto_examples/signals/images/sphx_glr_plot_univariate_polynomial_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import pandas as pd

    from indsl.signals.generator import line
    from indsl.signals.polynomial import univariate_polynomial


    start = pd.Timestamp("1975/05/09")
    end = pd.Timestamp("1975/05/15")

    # Create a time series

    data = line(start_date=start, end_date=end, slope=1e-4, intercept=0)
    coefficients_1 = [0, 1]
    coefficients_2 = [0, 1, 1]
    coefficients_3 = [0, 1, 1, 1]

    fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, figsize=(12, 10))
    props = dict(boxstyle="round", facecolor="wheat", alpha=0.5)

    ax1.plot(data, "bo", mec="b", markerfacecolor="None", markersize=4)
    ax1.text(
        0.05,
        0.95,
        "Input Time Series",
        transform=ax1.transAxes,
        fontsize=14,
        verticalalignment="top",
        bbox=props,
    )
    ax1.set_ylabel("Time Series")
    ax1.set_title("Univariate Polynomial ")


    ax2.plot(univariate_polynomial(data, coefficients_1), "bo", mec="b", markerfacecolor="None", markersize=4)
    ax2.text(
        0.05,
        0.95,
        "Polynomial of order 1",
        transform=ax2.transAxes,
        fontsize=14,
        verticalalignment="top",
        bbox=props,
    )
    ax2.set_ylabel("Time Series")


    ax3.plot(univariate_polynomial(data, coefficients_2), "bo", mec="b", markerfacecolor="None", markersize=4)
    ax3.text(
        0.05,
        0.95,
        "Polynomial of order 2",
        transform=ax3.transAxes,
        fontsize=14,
        verticalalignment="top",
        bbox=props,
    )
    ax3.set_ylabel("Time Series")

    ax4.plot(univariate_polynomial(data, coefficients_3), "bo", mec="b", markerfacecolor="None", markersize=4)
    ax4.text(
        0.05,
        0.95,
        "Polynomial of order 3",
        transform=ax4.transAxes,
        fontsize=14,
        verticalalignment="top",
        bbox=props,
    )
    ax4.set_ylabel("Time Series")


    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.362 seconds)


.. _sphx_glr_download_auto_examples_signals_plot_univariate_polynomial.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_univariate_polynomial.ipynb <plot_univariate_polynomial.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_univariate_polynomial.py <plot_univariate_polynomial.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_univariate_polynomial.zip <plot_univariate_polynomial.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
