.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/basis/plot_basis_1d.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_basis_plot_basis_1d.py: One-dimensional Basis ===================== .. GENERATED FROM PYTHON SOURCE LINES 6-17 .. code-block:: Python # Author: Steven Golovkine # License: MIT # Load packages import numpy as np from FDApy.representation import Basis from FDApy.representation import DenseArgvals from FDApy.visualization import plot .. GENERATED FROM PYTHON SOURCE LINES 18-19 The package include different basis functions to represent functional data. In this section, we are showing the building blocks of the representation of basis functions. To define a :class:`~FDApy.representation.Basis` object, we need to specify the name of the basis, the number of functions in the basis and the sampling points. The sampling points are defined as a :class:`~FDApy.representation.DenseArgvals`. .. GENERATED FROM PYTHON SOURCE LINES 22-23 We will show the basis functions for the Fourier, B-splines and Wiener basis. The number of functions in the basis is set to :math:`5` and the sampling points are defined as a :class:`~FDApy.representation.DenseArgvals` object with a hundred points between :math:`0` and :math:`1`. .. GENERATED FROM PYTHON SOURCE LINES 23-29 .. code-block:: Python # Parameters n_functions = 5 argvals = DenseArgvals({"input_dim_0": np.linspace(0, 1, 101)}) .. GENERATED FROM PYTHON SOURCE LINES 30-33 Fourier basis ------------- First, we will show the basis functions for the Fourier basis. The basis functions consist of the sine and cosine functions with a frequency that increases with the number of the function. Note that the first function is a constant function. This basis may be used to represent periodic functions. .. GENERATED FROM PYTHON SOURCE LINES 33-38 .. code-block:: Python basis = Basis(name="fourier", n_functions=n_functions, argvals=argvals) _ = plot(basis) .. image-sg:: /auto_examples/basis/images/sphx_glr_plot_basis_1d_001.png :alt: plot basis 1d :srcset: /auto_examples/basis/images/sphx_glr_plot_basis_1d_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-42 B-splines basis --------------- Second, we will show the basis functions for the B-splines basis. The basis functions are piecewise polynomials that are smooth at the knots. The number of knots is equal to the number of functions in the basis minus :math:`2`. This basis may be used to represent smooth functions. .. GENERATED FROM PYTHON SOURCE LINES 42-47 .. code-block:: Python basis = Basis(name="bsplines", n_functions=n_functions, argvals=argvals) _ = plot(basis) .. image-sg:: /auto_examples/basis/images/sphx_glr_plot_basis_1d_002.png :alt: plot basis 1d :srcset: /auto_examples/basis/images/sphx_glr_plot_basis_1d_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 48-51 Wiener basis ------------ Third, we will show the basis functions for the Wiener basis. The basis functions are the eigenfunctions of a Brownian process. This basis may be used to represent rough functions. .. GENERATED FROM PYTHON SOURCE LINES 51-55 .. code-block:: Python basis = Basis(name="wiener", n_functions=n_functions, argvals=argvals) _ = plot(basis) .. image-sg:: /auto_examples/basis/images/sphx_glr_plot_basis_1d_003.png :alt: plot basis 1d :srcset: /auto_examples/basis/images/sphx_glr_plot_basis_1d_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.272 seconds) .. _sphx_glr_download_auto_examples_basis_plot_basis_1d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_basis_1d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_basis_1d.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_basis_1d.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_