GAA-UAM / scikit-fda

Functional Data Analysis Python package
https://fda.readthedocs.io
BSD 3-Clause "New" or "Revised" License
308 stars 58 forks source link

New `FDataGrid.restrict` option `include_bounds`? #560

Closed ego-thales closed 1 year ago

ego-thales commented 1 year ago

Hi,

Currently, FDataGrid.restrict(domain) eliminates points outside of domain. As a consequence, the first (resp. last) grid point (in the 1D case) might be relatively far from the lower (resp. upper) bound of domain. In this case, after restriction, between the bound and the grid point, skfda will essentially use extrapolation, when only interpolation should occur, which might lower the accuracy of the "guess".

For example: tmp

This is why I propose to add an include_bounds option, that would interpolate at boundaries before restricting if the grid points don't include the domain values. The option default value should be discussed. If True might seem better, it will also silently add new grid_points, which might not be wanted.

What do you think about it? Élie

vnmabus commented 1 year ago

I thought a little bit about it when implementing the restrict method. I agree that this problem exists, specially for measurements which are not very dense. At that moment I did not thought about interpolating at the boundaries, which is probably a reasonable approach. I thus would love to add such an option.

I think that this option as proposed would also be applicable to high dimensional functions (surfaces and so on). If that is true I have nothing against it.

vnmabus commented 1 year ago

Solved in #561.