# The number of observations within the data are obtained using the function # :func:`~FDApy.irregular_functional.IrregularFunctional.n_obs`. # Get the number of observations for the object print(cd4.n_obs) ############################################################################### # The number of sampling points per observation is given by the function # :func:`~FDApy.irregular_functional.IrregularFunctional.n_points`. # Retrieve the mean number of sampling points for the object print(cd4.n_points) ############################################################################### # The dimension of the data is given by the function # :func:`~FDApy.irregular_functional.IrregularFunctional.n_dim`. # Get the dimension of the domain of the observations print(cd4.n_dim) ############################################################################### # The extraction of observations is also easily done. # Extract observations from the object print(cd4[5:8]) ############################################################################### # Finally, we can plot the data. _ = plot(cd4)
# Print out an univariate functional data object. # Print univariate functional data print(temperature) ############################################################################### # Print out a multivariate functional data object. # Print multivariate functional data print(canadWeather) ############################################################################### # We can plot the data. # Plot the univariate functional data _ = plot(temperature) ############################################################################### # The attributs of the univariate functional data classes can easily be # accessed. ############################################################################### # The sampling points of the data can easily be accessed. # Accessing the argvals of the object print(precipitation.argvals) ############################################################################### # The number of observations within the data are obtained using the function # :func:`~FDApy.univariate_functional.UnivariateFunctional.n_obs`.
from FDApy.visualization.plot import plot from FDApy.misc.loader import read_csv ############################################################################### # Load the data into Pandas dataframe temperature = read_csv('./data/canadian_temperature_daily.csv', index_col=0) ############################################################################### # Perform a univariate functional PCA and explore the results. # Perform a univariate FPCA on dailyTemp. fpca = UFPCA(n_components=0.99) fpca.fit(temperature) # Plot the results of the FPCA (eigenfunctions) _ = plot(fpca.eigenfunctions) ############################################################################### # Compute the scores of the dailyTemp data into the eigenfunctions basis using # numerical integration. # Compute scores temperature_proj = fpca.transform(temperature, method='NumInt') # Plot the projection of the data onto the eigenfunctions _ = pd.plotting.scatter_matrix(pd.DataFrame(temperature_proj), diagonal='kde') ############################################################################### # Then, we can test if the reconstruction of the data is good. # Test if the reconstruction is good.
from FDApy.representation.simulation import Brownian from FDApy.visualization.plot import plot ############################################################################### # Generate some data as Fractional Brownian motion. # # Simulate some fractional brownian motions. brownian = Brownian(name='standard') brownian.new(n_obs=1000, argvals=np.linspace(0, 1, 301)) brownian.add_noise(0.05) # Plot some simulations _ = plot(brownian.noisy_data) ############################################################################### # Now, we will smooth the data according the methodology from (add ref). # # Smooth the data data_smooth = brownian.noisy_data.smooth(points=0.5, neighborhood=14) # Plot of the smoothing data _ = plot(data_smooth) ############################################################################### # In order to look more precisely at the smoothing results, let's plot one # individual curve, along its noisy and smoothed version. #
# License: MIT # shinx_gallery_thumbnail_number = 2 import numpy as np from FDApy.representation.simulation import Brownian, KarhunenLoeve from FDApy.visualization.plot import plot ############################################################################### # Now, we will simulate some curves data using the Karhunen-Loève expansion. # kl = KarhunenLoeve(name='bsplines', n_functions=5) kl.new(n_obs=100, argvals=np.linspace(0, 1, 301)) _ = plot(kl.data) ############################################################################### # We can also add some noise to the data. # # First, we consider homoscedastic noise. Thus, we add realizations of the # random variable :math:`\varepsilon \sim \mathcal{N}(0, \sigma^2)` to the # data. # # Add some noise to the simulation. kl.add_noise(0.05) # Plot the noisy simulations _ = plot(kl.noisy_data)
index_col=0) temperature = read_csv('./data/canadian_temperature_daily.csv', index_col=0) # Create multivariate functional data for the Canadian weather data. canadWeather = MultivariateFunctionalData([precipitation, temperature]) ############################################################################### # Perform a multivariate functional PCA and explore the results. # Perform multivariate FPCA mfpca = MFPCA(n_components=[0.99, 0.95]) mfpca.fit(canadWeather, method='NumInt') # Plot the results of the FPCA (eigenfunctions) fig, (ax1, ax2) = plt.subplots(1, 2) _ = plot(mfpca.basis[0], ax=ax1) _ = plot(mfpca.basis[1], ax=ax2) ############################################################################### # Compute the scores of the dailyTemp data into the eigenfunctions basis using # numerical integration. # Compute the scores canadWeather_proj = mfpca.transform(canadWeather) # Plot the projection of the data onto the eigenfunctions _ = pd.plotting.scatter_matrix(pd.DataFrame(canadWeather_proj), diagonal='kde') ############################################################################### # Then, we can test if the reconstruction of the data is good.