Top Description Fields Constructors Methods
org.apache.commons.math3.analysis.interpolation

public Class AkimaSplineInterpolator

extends Object
implements UnivariateInterpolator
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator
Imports
org.apache.commons.math3.analysis.polynomials.PolynomialFunction, .PolynomialSplineFunction, org.apache.commons.math3.exception.DimensionMismatchException, .NonMonotonicSequenceException, .NullArgumentException, .NumberIsTooSmallException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.util.FastMath, .MathArrays, .Precision

Computes a cubic spline interpolation for the data set using the Akima algorithm, as originally formulated by Hiroshi Akima in his 1970 paper "A New Method of Interpolation and Smooth Curve Fitting Based on Local Procedures." J. ACM 17, 4 (October 1970), 589-602. DOI=10.1145/321607.321609 http://doi.acm.org/10.1145/321607.321609

This implementation is based on the Akima implementation in the CubicSpline class in the Math.NET Numerics library. The method referenced is CubicSpline.InterpolateAkimaSorted

The interpolate method returns a PolynomialSplineFunction consisting of n cubic polynomials, defined over the subintervals determined by the x values, x[0] < x[i] ... < x[n]. The Akima algorithm requires that n >= 5.

Field Summary

Modifier and TypeField and Description
private static final int
MINIMUM_NUMBER_POINTS

The minimum number of points that are needed to compute the function.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private double

Returns:

the derivative
differentiateThreePoint
(double[]
x values to calculate the numerical derivative with
xvals
,
double[]
y values to calculate the numerical derivative with
yvals
,
int
index of the elemnt we are calculating the derivative around
indexOfDifferentiation
,
int
index of the first element to sample for the three point method
indexOfFirstSample
,
int
index of the second element to sample for the three point method
indexOfSecondsample
,
int
index of the third element to sample for the three point method
indexOfThirdSample
)

Three point differentiation helper, modeled off of the same method in the Math.NET CubicSpline class.

public PolynomialSplineFunction

Returns:

a function which interpolates the data set
interpolate
(double[]
the arguments for the interpolation points
xvals
,
double[]
the values for the interpolation points
yvals
)

Implements org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator.interpolate.

Deprecated as a consequence of PolynomialSplineFunction being deprecated.

Computes an interpolating function for the data set.

private PolynomialSplineFunction

Returns:

polynomial that fits the function
interpolateHermiteSorted
(double[]
x values for interpolation
xvals
,
double[]
y values for interpolation
yvals
,
double[]
first derivative values of the function
firstDerivatives
)
Deprecated as a consequence of PolynomialSplineFunction being deprecated.

Creates a Hermite cubic spline interpolation from the set of (x,y) value pairs and their derivatives.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MINIMUM_NUMBER_POINTSback to summary
private static final int MINIMUM_NUMBER_POINTS

The minimum number of points that are needed to compute the function.

Constructor Detail

AkimaSplineInterpolatorback to summary
public AkimaSplineInterpolator()

Method Detail

differentiateThreePointback to summary
private double differentiateThreePoint(double[] xvals, double[] yvals, int indexOfDifferentiation, int indexOfFirstSample, int indexOfSecondsample, int indexOfThirdSample)

Three point differentiation helper, modeled off of the same method in the Math.NET CubicSpline class. This is used by both the Apache Math and the Math.NET Akima Cubic Spline algorithms

Parameters
xvals:double[]

x values to calculate the numerical derivative with

yvals:double[]

y values to calculate the numerical derivative with

indexOfDifferentiation:int

index of the elemnt we are calculating the derivative around

indexOfFirstSample:int

index of the first element to sample for the three point method

indexOfSecondsample:int

index of the second element to sample for the three point method

indexOfThirdSample:int

index of the third element to sample for the three point method

Returns:double

the derivative

interpolateback to summary
public PolynomialSplineFunction interpolate(double[] xvals, double[] yvals) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException

Implements org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator.interpolate.

Deprecated

as a consequence of PolynomialSplineFunction being deprecated. See corresponding docs for further information.

Computes an interpolating function for the data set.

Parameters
xvals:double[]

the arguments for the interpolation points

yvals:double[]

the values for the interpolation points

Returns:PolynomialSplineFunction

a function which interpolates the data set

Exceptions
DimensionMismatchException:
if xvals and yvals have different sizes.
NumberIsTooSmallException:
if the size of xvals is smaller than 5.
NonMonotonicSequenceException:
if xvals is not sorted in strict increasing order.
interpolateHermiteSortedback to summary
private PolynomialSplineFunction interpolateHermiteSorted(double[] xvals, double[] yvals, double[] firstDerivatives)

Deprecated

as a consequence of PolynomialSplineFunction being deprecated. See corresponding docs for further information.

Creates a Hermite cubic spline interpolation from the set of (x,y) value pairs and their derivatives. This is modeled off of the InterpolateHermiteSorted method in the Math.NET CubicSpline class.

Parameters
xvals:double[]

x values for interpolation

yvals:double[]

y values for interpolation

firstDerivatives:double[]

first derivative values of the function

Returns:PolynomialSplineFunction

polynomial that fits the function