Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Discretized function representation#
Shows how to make a discretized representation of a function.
# Author: Carlos Ramos Carreño <vnmabus@gmail.com>
# License: MIT
# sphinx_gallery_thumbnail_number = 2
We will construct a dataset containing several sinusoidal functions with random displacements.
import numpy as np
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)
])
The FDataGrid class is used for datasets containing discretized functions that are measured at the same points.
We can plot the measured values of each function in a scatter plot.
import matplotlib.pyplot as plt
fd.scatter(s=0.5)
plt.show()

We can also plot the interpolated functions.

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