Akima Module

Module to create piecewise cubic polynomials (cubic subsplines) from x,y coordinates. Akima subsplines are more flexible than standard cubic splines because the are NOT continuous in the function curvature, thereby diminishing oscillating behaviour.

Types

Type Description

SubSplineCoef

Subsplines differ from regular splines because they are discontinuous in the second derivative.

Functions and values

Function or value Description

definiteIntegral integrateF xVal1 xVal2

Full Usage: definiteIntegral integrateF xVal1 xVal2

Parameters:
    integrateF : float -> float
    xVal1 : float - X value from where the integral should be calculated.
    xVal2 : float - X value up to which the integral should be calculated.

Returns: float Integral (area under the curve) from x=xVal1 to x=xVal2

Returns integral from interpolating function from x=xVal1 to x=xVal2.

integrateF : float -> float
xVal1 : float

X value from where the integral should be calculated.

xVal2 : float

X value up to which the integral should be calculated.

Returns: float

Integral (area under the curve) from x=xVal1 to x=xVal2

getFirstDerivative splineCoeffs xVal

Full Usage: getFirstDerivative splineCoeffs xVal

Parameters:
    splineCoeffs : SubSplineCoef - Interpolation functions coefficients.
    xVal : float - X value of which the slope should be predicted.

Returns: float Function that takes an x value and returns slope.

Returns function that takes x value and predicts the corresponding slope.

Second derivative (curvature) is NOT continuous at knots to allow higher flexibility to reduce oscillations! For reference see: http://www.dorn.org/uni/sls/kap06/f08_0204.htm.

splineCoeffs : SubSplineCoef

Interpolation functions coefficients.

xVal : float

X value of which the slope should be predicted.

Returns: float

Function that takes an x value and returns slope.

Example

 
 // e.g. days since a certain event
 let xData = vector [|0.;1.;5.;4.;3.;|]
 // some measured feature
 let yData = vector [|1.;5.;4.;13.;17.|]

 // get coefficients for piecewise interpolating cubic polynomials
 let coefficients = 
     Akima.interpolate xData yData

 // get function to predict slope
 let interpolFunc = 
     Akima.getFirstDerivative coefficients

 // get slope at x=3.4
 interpolFunc 3.4

getSecondDerivative splineCoeffs xVal

Full Usage: getSecondDerivative splineCoeffs xVal

Parameters:
    splineCoeffs : SubSplineCoef - Interpolation functions coefficients.
    xVal : float - X value of which the curvature should be predicted.

Returns: float Function that takes an x value and returns curvature.

Returns function that takes x value and predicts the corresponding interpolating curvature.

Second derivative (curvature) is NOT continuous at knots to allow higher flexibility to reduce oscillations! For reference see: http://www.dorn.org/uni/sls/kap06/f08_0204.htm.

splineCoeffs : SubSplineCoef

Interpolation functions coefficients.

xVal : float

X value of which the curvature should be predicted.

Returns: float

Function that takes an x value and returns curvature.

Example

 
 // e.g. days since a certain event
 let xData = vector [|0.;1.;5.;4.;3.;|]
 // some measured feature
 let yData = vector [|1.;5.;4.;13.;17.|]

 // get coefficients for piecewise interpolating cubic polynomials
 let coefficients = 
     Akima.interpolate xData yData

 // get function to predict curvature
 let interpolFunc = 
     Akima.getSecondDerivative coefficients

 // get curvature at x=3.4
 interpolFunc 3.4

integrate splineCoeffs xVal

Full Usage: integrate splineCoeffs xVal

Parameters:
    splineCoeffs : SubSplineCoef - Interpolation functions coefficients.
    xVal : float - X value up to which the integral should be calculated.

Returns: float Integral (area under the curve) from x=0 to x=xVal

Returns integral from interpolating function from x=0 to x=xVal.

splineCoeffs : SubSplineCoef

Interpolation functions coefficients.

xVal : float

X value up to which the integral should be calculated.

Returns: float

Integral (area under the curve) from x=0 to x=xVal

interpolate xValues yValues

Full Usage: interpolate xValues yValues

Parameters:
    xValues : float[] - Note: Must not contain duplicate x values (use Approximation.regularizeValues to preprocess data!)
    yValues : float[] - function value at x values

Returns: SubSplineCoef Coefficients that define the interpolating function.

Computes coefficients for piecewise interpolating subsplines.

Second derivative (curvature) is NOT continuous at knots to allow higher flexibility to reduce oscillations! For reference see: http://www.dorn.org/uni/sls/kap06/f08_0204.htm.

xValues : float[]

Note: Must not contain duplicate x values (use Approximation.regularizeValues to preprocess data!)

yValues : float[]

function value at x values

Returns: SubSplineCoef

Coefficients that define the interpolating function.

Example

 
 // e.g. days since a certain event
 let xData = vector [|0.;1.;5.;4.;3.;|]
 // some measured feature
 let yData = vector [|1.;5.;4.;13.;17.|]

 // get coefficients for piecewise interpolating cubic polynomials
 let coefficients = 
     Akima.interpolate xData yData

interpolateHermiteSorted xValues yValues firstDerivatives

Full Usage: interpolateHermiteSorted xValues yValues firstDerivatives

Parameters:
    xValues : float[] - x values that are sorted ascending. Note: Must not contain duplicate x values (use Approximation.regularizeValues to preprocess data!)
    yValues : float[] - function value at x values
    firstDerivatives : float[] - first derivatives at x values

Returns: SubSplineCoef Coefficients that define the interpolating function.

Computes coefficients for piecewise interpolating subsplines.

Second derivative (curvature) is NOT continuous at knots to allow higher flexibility to reduce oscillations! For reference see: http://www.dorn.org/uni/sls/kap06/f08_0204.htm.

xValues : float[]

x values that are sorted ascending. Note: Must not contain duplicate x values (use Approximation.regularizeValues to preprocess data!)

yValues : float[]

function value at x values

firstDerivatives : float[]

first derivatives at x values

Returns: SubSplineCoef

Coefficients that define the interpolating function.

Example

 
 // e.g. days since a certain event
 let xData = vector [|0.;1.;5.;4.;3.;|]
 // some measured feature
 let yData = vector [|1.;5.;4.;13.;17.|]

 // get coefficients for piecewise interpolating cubic polynomials
 let coefficients = 
     Akima.interpolate xData yData

predict splineCoeffs xVal

Full Usage: predict splineCoeffs xVal

Parameters:
    splineCoeffs : SubSplineCoef - Interpolation functions coefficients.
    xVal : float - X value of which the y value should be predicted.

Returns: float Function that takes an x value and returns function value.

Returns function that takes x value and predicts the corresponding interpolating y value.

Second derivative (curvature) is NOT continuous at knots to allow higher flexibility to reduce oscillations! For reference see: http://www.dorn.org/uni/sls/kap06/f08_0204.htm.

splineCoeffs : SubSplineCoef

Interpolation functions coefficients.

xVal : float

X value of which the y value should be predicted.

Returns: float

Function that takes an x value and returns function value.

Example

 
 // e.g. days since a certain event
 let xData = vector [|0.;1.;5.;4.;3.;|]
 // some measured feature
 let yData = vector [|1.;5.;4.;13.;17.|]

 // get coefficients for piecewise interpolating cubic polynomials
 let coefficients = 
     Akima.interpolate xData yData

 // get function to predict y value
 let interpolFunc = 
     Akima.predict coefficients

 // get function value at x=3.4
 interpolFunc 3.4