Integrals.jl icon indicating copy to clipboard operation
Integrals.jl copied to clipboard

Add `cumulative` kwarg for solving `SampledIntegralProblem`

Open sathvikbhagavan opened this issue 2 years ago • 5 comments

sathvikbhagavan avatar Sep 25 '23 09:09 sathvikbhagavan

@ChrisRackauckas can you review this?

sathvikbhagavan avatar Sep 29 '23 17:09 sathvikbhagavan

I guess it's fine but why should this be done in the solver? What is this doing that cumsum after the solver does not?

ChrisRackauckas avatar Sep 30 '23 01:09 ChrisRackauckas

What is this doing that cumsum after the solver does not?

So, the aim is to get back an integrated time series back from a time series. Basically collecting intermediate results.

sathvikbhagavan avatar Sep 30 '23 03:09 sathvikbhagavan

@sathvikbhagavan I read the pr and I'm not sure this actually does what I would expect. Do you actually need the accuracy of a quadrature rule, or would cumsum suffice?

My perspective is that if new quadrature schemes are added for which all the weights change when a single data point is added, then cumulative integrals are equivalent to doing a sampled integral problem for each sub-sequence. If my data represents a time series and I want the best estimate to the integral at each time step, I would solve a sampled integral problem for each sub-sequence of the data, e.g. for all [first(data, n) for n in 1:length(data)]. This is subtly different than cumsum because the quadrature weights used may differ for different numbers of points.

For example, consider the difference between cumsum and applying the trapezoidal rule, which is that in the latter, the first and last data points are given half the weight. When doing a cumulative trapezoidal rule, the cumulative integral would need updates from the last two points in order to be the trapezoidal rule. However, this pr just uses the partial sums of the quadrature rule as the cumulative integrals, which are not themselves quadratures.

lxvm avatar Oct 30 '23 00:10 lxvm

@sathvikbhagavan It has been 6 months since you opened this pr so I was wondering if you still need it?

With #222 I'm skeptical that using the partial sums is equivalent to computing the integral of the time series

lxvm avatar Mar 02 '24 23:03 lxvm