Home

Awesome

Build Status

SimplePCHIP

This package provide functionality to perform piecewise cubic hermite interpolating polynomial (PCHIP) interpolation of arbitrarily spaced 1-dimensional data.

Summary

The basic use of SimplePCHIP can be illustrated with the following snippet

using SimplePCHIP
using Gadfly

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 = interpolate(xs, ys)

xrange = range(xs[1], stop=xs[end], length=100)
yinterpolated = [itp(x) for x ∈ xrange]

plot(layer(x=xrange, y=yinterpolated, Geom.line),
     layer(x=xs, y=ys, Geom.point))

Why PCHIP?

PCHIP interpolation preserves monotonicity. E.g., if input data point are monotonically increasing, so will the interpolated points. Also, the interpolated points will not overshoot.

It can be illustrated by zooming in on the plot above, at around x=1.2 and x=10.0,

x=1.2 x=10.0

See also

SimplePCHIP was created to provide interpolation similar to SciPy's PchipInterpolation.

For further details on PCHIP interpolation, there is of course a wikipedia article about Monotone cubic interpolation, also this pdf about interpolation (with a focus on Matlab) provides details on PCHIP interpolation.