.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_discrete_representation.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_auto_examples_plot_discrete_representation.py: Discretized function representation =================================== Shows how to make a discretized representation of a function. .. GENERATED FROM PYTHON SOURCE LINES 7-18 .. code-block:: Python # Author: Carlos Ramos CarreƱo # License: MIT # sphinx_gallery_thumbnail_number = 2 from skfda import FDataGrid import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 19-21 We will construct a dataset containing several sinusoidal functions with random displacements. .. GENERATED FROM PYTHON SOURCE LINES 21-27 .. code-block:: Python random_state = np.random.RandomState(0) grid_points = np.linspace(0, 1) data = np.array([np.sin((grid_points + random_state.randn()) * 2 * np.pi) for _ in range(5)]) .. GENERATED FROM PYTHON SOURCE LINES 28-30 The FDataGrid class is used for datasets containing discretized functions that are measured at the same points. .. GENERATED FROM PYTHON SOURCE LINES 30-38 .. code-block:: Python fd = FDataGrid(data, grid_points, dataset_name='Sinusoidal curves', argument_names=['t'], coordinate_names=['x(t)']) fd = fd[:5] .. GENERATED FROM PYTHON SOURCE LINES 39-40 We can plot the measured values of each function in a scatter plot. .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python fd.scatter(s=0.5) .. image-sg:: /auto_examples/images/sphx_glr_plot_discrete_representation_001.png :alt: Sinusoidal curves :srcset: /auto_examples/images/sphx_glr_plot_discrete_representation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 44-45 We can also plot the interpolated functions. .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: Python fd.plot() .. image-sg:: /auto_examples/images/sphx_glr_plot_discrete_representation_002.png :alt: Sinusoidal curves :srcset: /auto_examples/images/sphx_glr_plot_discrete_representation_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.300 seconds) .. _sphx_glr_download_auto_examples_plot_discrete_representation.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/GAA-UAM/scikit-fda/develop?filepath=examples/plot_discrete_representation.py :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_discrete_representation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_discrete_representation.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_