You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Integration procedures for Interpolation and LinearRegression #291
Integrals can easily be calculated for step functions, linear splines, polynomials and splines. These procedures are missing for most of the interpolation and regression modules.
Important: unit tests should cover both, negative x and negative y values!
Cubic spline interpolation — implemented in this PR
I also added LinearSpline.integrate (not in the original checklist but a natural addition).
Regression — these remain unimplemented (simple linear regression, polynomial regression, smoothing spline).
The PR uses closed-form antiderivatives for all three new functions and includes 5 tests against known analytical results (1198/1198 pass). The Hermite case is more involved since it requires expressing the integral in terms of the cubic Hermite basis functions; happy to tackle that in a follow-up if useful.
PR #375 added functions to calculate definite integrals for LinearSpline, Step, and CubicSpline. Akima also has definite integrals already.
I also think that for Polynomial interpolation, both the integral function as well as the definite integrals have been added in 6a9038e. Unit tests for that seem to be missing though.
@bvenn Just to better my understanding going forward, is this issue specifically asking to implement calculations for definite integrals or for integral functions (or both)?
@annacwe Originally this issue targeted the solution addressed in e.g. #375 to enable calculation of definite integrals from the given functions. Could you rephrase what you mean with "integral functions"?
If my understanding is correct the current approach calculates the definite integral via
By "integral function" I meant the antiderivative. My thinking was that if the goal was to support both the antiderivative and the calculation of definite integrals, that could influence in what order we approach implementation.
The question came up because I felt that the existing implementation wasn't entirely consistent.
For Polynomials, there are both, if I understand correctly:
integrate, which returns the coefficients of the antiderivative
getIntegral, which computed a definite integral
Whereas for Akima subsplines:
integrate, which returns the integral from 0.0 to xVal
definiteIntegral, which returns the integral from xVal1 to xVal2
And with the solution from #375, there is only the definite integral.
That's why I was unsure what the overall intention was or whether this is simply the result of a historical development.
Okay, now I see you point. It's a valid concern. Naturally I think both would be a great to have.
Naturally getIntegral a b or integrate a b should be the definite integral between both boundaries. I'm currently don't have a strong opinion regarding the naming. The antiderivative coefficient is a whole new use case that I haven't had in mind. Whatever the member would be called, as you mentioned it just should be coherent across the library
Activity
feat: add integrate function to LinearSpline, Step, and CubicSpline
github-actions commentedon Apr 13, 2026
🤖 This is an automated response from Repo Assist.
I've created a draft PR implementing several of the integration functions from this checklist. Here's the current status:
Interpolation
Akima.integratealready existed ✓Polynomial.integratealready existed ✓I also added
LinearSpline.integrate(not in the original checklist but a natural addition).Regression — these remain unimplemented (simple linear regression, polynomial regression, smoothing spline).
The PR uses closed-form antiderivatives for all three new functions and includes 5 tests against known analytical results (1198/1198 pass). The Hermite case is more involved since it requires expressing the integral in terms of the cubic Hermite basis functions; happy to tackle that in a follow-up if useful.
annacwe commentedon Jul 21, 2026
PR #375 added functions to calculate definite integrals for LinearSpline, Step, and CubicSpline. Akima also has definite integrals already.
I also think that for Polynomial interpolation, both the integral function as well as the definite integrals have been added in 6a9038e. Unit tests for that seem to be missing though.
@bvenn Just to better my understanding going forward, is this issue specifically asking to implement calculations for definite integrals or for integral functions (or both)?
bvenn commentedon Oct 11, 2026
@annacwe Originally this issue targeted the solution addressed in e.g. #375 to enable calculation of definite integrals from the given functions. Could you rephrase what you mean with "integral functions"?
If my understanding is correct the current approach calculates the definite integral via
With integral function do you mean:
where the integral function itself is returned?
If so, this could easily be realized using closures and the current implementation
Or do you mean a standard interval starting at 0.0 as integral function?
annacwe commentedon Oct 11, 2026
By "integral function" I meant the antiderivative. My thinking was that if the goal was to support both the antiderivative and the calculation of definite integrals, that could influence in what order we approach implementation.
The question came up because I felt that the existing implementation wasn't entirely consistent.
For Polynomials, there are both, if I understand correctly:
Whereas for Akima subsplines:
And with the solution from #375, there is only the definite integral.
That's why I was unsure what the overall intention was or whether this is simply the result of a historical development.
bvenn commentedon Oct 11, 2026
Okay, now I see you point. It's a valid concern. Naturally I think both would be a great to have.
Naturally
getIntegral a borintegrate a bshould be the definite integral between both boundaries. I'm currently don't have a strong opinion regarding the naming. The antiderivative coefficient is a whole new use case that I haven't had in mind. Whatever the member would be called, as you mentioned it just should be coherent across the library