Skip to content

ScottLemon/PCHIPInterpolation.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PCHIPInterpolation.jl

Build Status Coverage

PCHIP (Piecewise Cubic Hermite Interpolating Polynomial) spline interpolation of arbitrarily spaced one-dimensional data in Julia. This package is a fork of SimplePCHIP with some extra features.

PCHIP interpolation preserves monotonicity (i.e., it will not over- or undershoot monotonic data points). Continue reading for an example.

Summary

Create a PCHIP interpolator

using PCHIPInterpolation

xs = [0.0,  1.2,  2.0,  5.0, 10.0, 11.0]
ys = [2.0,  2.1,  1.0,  0.0,  0.0,  3.0]

itp = Interpolator(xs, ys)

Evaluate

y = itp(1.5) # At a single point
ys = itp.(xs) # At multiple points

Plot

using Plots

plot(itp, label="PCHIP")

Plot

Compute a definite integral

integral = integrate(itp, 1, 3) # Integral between 1 and 3. 

About

Monotonic cubic interpolation in Julia

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Julia 100.0%