Skip to content

[Feature Request] Integration procedures for Interpolation and LinearRegression #291

Open

Description

@bvenn

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!

Interpolation

  • step interpolation
  • akima interpolation
  • hermite interpolation
  • polynomial interpolation
  • cubic spline interpolation

Regression

  • simple linear regression
  • polynomial regression
  • smoothing spline
  • (optional) robust simple linear regression

Activity

  1. github-actions commented on Apr 13, 2026

    @github-actions
    Contributor

    🤖 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

    • Step interpolation — implemented in this PR
    • Akima interpolation — Akima.integrate already existed ✓
    • Hermite interpolation — still missing
    • Polynomial interpolation — Polynomial.integrate already existed ✓
    • 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.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a
    
  2. annacwe commented on Jul 21, 2026

    @annacwe
    Collaborator

    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)?

  3. bvenn commented on Oct 11, 2026

    @bvenn
    MemberAuthor

    @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

    let integralValue: float = getIntegralBetween coefficients lowerBound upperBound

    With integral function do you mean:

    let integralFun lowerBound upperBound: (float  -> float -> float) = getIntegral coefficients

    where the integral function itself is returned?

    If so, this could easily be realized using closures and the current implementation

    let integralFun = 
    	fun a b -> getIntegralBetween coefficients a b

    Or do you mean a standard interval starting at 0.0 as integral function?

  4. annacwe commented on Oct 11, 2026

    @annacwe
    Collaborator

    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.

  5. bvenn commented on Oct 11, 2026

    @bvenn
    MemberAuthor

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions