Class CubicSpline
- java.lang.Object
-
- dev.nm.analysis.curvefit.interpolation.univariate.CubicSpline
-
- All Implemented Interfaces:
CurveFitting,Interpolation
public class CubicSpline extends Object implements Interpolation
The cubic spline interpolation fits a cubic polynomial between each pair of adjacent points such that adjacent cubics are continuous in their first and second derivatives.Various common end conditions are implemented: natural, clamped, and not-a-knot.
With the given end condition, this implementation also provides a default linear extrapolation at two ends whose slope matches the slope of the first or last splines. That means, the second derivative at both ends are zero.
- See Also:
- Wikipedia: Spline interpolation
-
-
Constructor Summary
Constructors Constructor Description CubicSpline()Constructs an instance with default end conditions which fits natural splines, meaning that the second derivative at both ends are zero.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CubicSplineclamped()Constructs an instance with end conditions which fits clamped splines, and the first derivative at both ends are zero.static CubicSplineclamped(double df1, double dfn)Constructs an instance with end conditions which fits clamped splines, meaning that the first derivative at both ends equal to the given values.UnivariateRealFunctionfit(OrderedPairs pairs)Fit a real valued function from a discrete set of data points.static CubicSplinenatural()Constructs an instance with end conditions which fits natural splines, meaning that the second derivative at both ends are zero.static CubicSplinenotAKnot()Constructs an instance with end conditions which fits not-a-knot splines, meaning that continuity of the third derivative at the second and the next-to-last knots are forced.
-
-
-
Method Detail
-
natural
public static CubicSpline natural()
Constructs an instance with end conditions which fits natural splines, meaning that the second derivative at both ends are zero.- Returns:
- the instance
-
clamped
public static CubicSpline clamped()
Constructs an instance with end conditions which fits clamped splines, and the first derivative at both ends are zero.- Returns:
- the instance
-
clamped
public static CubicSpline clamped(double df1, double dfn)
Constructs an instance with end conditions which fits clamped splines, meaning that the first derivative at both ends equal to the given values.- Parameters:
df1- the first derivative at the first pointdfn- the first derivative at the last point- Returns:
- the instance
-
notAKnot
public static CubicSpline notAKnot()
Constructs an instance with end conditions which fits not-a-knot splines, meaning that continuity of the third derivative at the second and the next-to-last knots are forced.- Returns:
- the instance
-
fit
public UnivariateRealFunction fit(OrderedPairs pairs)
Description copied from interface:InterpolationFit a real valued function from a discrete set of data points. The interpolated function must pass through all the given points.- Specified by:
fitin interfaceCurveFitting- Specified by:
fitin interfaceInterpolation- Parameters:
pairs-- Returns:
- the interpolated function
-
-