Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integral of discretized functional data #619

Open
pcuestas opened this issue Jun 30, 2024 · 0 comments
Open

Integral of discretized functional data #619

pcuestas opened this issue Jun 30, 2024 · 0 comments

Comments

@pcuestas
Copy link
Contributor

pcuestas commented Jun 30, 2024

This issue addresses the definition of the FData.integrate() method for both FDataGrid and FDataIrregular objects; in particular, how this integral should be defined for any discretized functional observation.

To simplify, I will speak about $[a, b] \to \mathbb{R}$ functional observations.

(This issue is related to #609 )


Given a discretized functional observation x (an element of an FDataGrid or an FDataIrregular object):

  • Let $D = [a, b]$ be its domain.
  • Let points = { $t_0 < t_1 < \dots < t_{M-1}$ } be its discretization grid (where $a \leq t_0, t_{M-1} \leq b$).

Currently, the integral of such an observation x is computed with the function scipy.integrate.simpson called like this:

scipy.integrate.simpson(x(points), points)

meaning that the integral is computed over the interval $[t_0, t_{M-1}]$. That is, we are computing

$$\int_{[t_0, t_{M-1}]} x(t)\ dt,$$

when we should be computing

$$ \int_{[a, b]} x(t)\ dt = \int_{[a, t_0]} x(t)\ dt + \int_{[t_0, t_{M-1}]} x(t)\ dt + \int_{[t_{M-1}, b]} x(t)\ dt. $$

So, the problem arises:

How to calculate $\int_{[a, t_0]} x(t)\ dt$ and $\int_{[t_{M-1}, b]} x(t)\ dt$?

There are formulas for numeric integration when the ends of the integral are open (i.e. when either $a \neq t_0$ or $t_{M-1} \neq b)$. However, we have only found them for equally spaced grids, which is not generally our case.

Some weeks ago, I talked briefly about how we should solve this with @vnmabus and Alberto Suarez. A strong conclusion was not reached, although Alberto argued that a very simple solution is as good as any, and we did not find anything wrong with that reasoning. In that spirit, I'll write down the two options that were proposed and open the discussion of which shall be chosen (among these or other possible solutions).

Option 1: fill the ends with a constant value

Approximate the integrals as follows:

$$\int_{[a, t_0]} x(t)\ dt :\approx \int_{[a, t_0]} x(t_0)\ dt = x(t_0) (t_0 - a),$$

$$\int_{[a, t_0]} x(t)\ dt :\approx \int_{[t_{M-1}, b]} x(t_{M-1})\ dt = x(t_{M-1}) (b - t_{M-1}).$$

Option 2: redefine the ends of the domain and integrate over the "augmented grid"

Redefine the grid to points_augmented = { $a, t_0, \dots, t_{M-1}, b$ } and $x(a) := x(t_0)$, $x(b) := x(t_{M-1})$ and compute the integral of x over $[a, b]$ as

scipy.integrate.simpson(x(points_augmented), points_augmented)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant