Skip to content

Add monotonic cubic spline (PCHIP) interpolation#335

Merged
josevalim merged 1 commit into
elixir-nx:mainfrom
RicardoSantos-99:add-monotonic-cubic-spline
Jul 11, 2026
Merged

Add monotonic cubic spline (PCHIP) interpolation#335
josevalim merged 1 commit into
elixir-nx:mainfrom
RicardoSantos-99:add-monotonic-cubic-spline

Conversation

@RicardoSantos-99

Copy link
Copy Markdown
Contributor

Adds Scholar.Interpolation.MonotonicCubicSpline, a piecewise cubic Hermite interpolant whose knot derivatives are chosen with the Fritsch-Carlson method so the curve stays monotonic where the data is monotonic and does not overshoot around local extrema (equivalent to scipy.interpolate.PchipInterpolator).

The power-basis coefficient layout and predict/3 are shared with CubicSpline, so only the derivative computation differs. Reference values in the tests were taken from SciPy.

Closes #322

Adds Scholar.Interpolation.MonotonicCubicSpline, a piecewise cubic
Hermite interpolant whose knot derivatives are chosen with the
Fritsch-Carlson method so the curve stays monotonic where the data is
monotonic and does not overshoot around local extrema (equivalent to
scipy.interpolate.PchipInterpolator).

The power-basis coefficient layout and predict/3 are shared with
CubicSpline, so only the derivative computation differs. Reference
values in the tests were taken from SciPy.

Closes elixir-nx#322
@josevalim josevalim merged commit 2166c43 into elixir-nx:main Jul 11, 2026
1 of 2 checks passed
@josevalim

Copy link
Copy Markdown
Contributor

💚 💙 💜 💛 ❤️

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

Successfully merging this pull request may close these issues.

Add Monotonic Cubic Spline Interpolation

2 participants