Hermite Module

Hermite cubic splines are defined by the function values and their slopes (first derivatives). If the slopws are unknown, they must be estimated.

Types

Type Description

HermiteCoef

Functions and values

Function or value Description

interpolate xData yData

Full Usage: interpolate xData yData

Parameters:
    xData : Vector<float> - Note: Must not contain duplicate x values (use Approximation.regularizeValues to preprocess data!)
    yData : Vector<float> - function value at x values

Returns: HermiteCoef Coefficients that define the interpolating function.

Computes coefficients for piecewise interpolating splines.

Second derivative (curvature) is NOT necessarily continuous at knots to allow higher flexibility to reduce oscillations!

xData : Vector<float>

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

yData : Vector<float>

function value at x values

Returns: HermiteCoef

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 = 
     CubicSpline.Hermite.interpolate xData yData

interpolatePreserveMonotonicity xData yData

Full Usage: interpolatePreserveMonotonicity xData yData

Parameters:
    xData : Vector<float>
    yData : Vector<float> - function value at x values

Returns: HermiteCoef Coefficients that define the interpolating function.

Computes coefficients for piecewise interpolating splines. If the knots are monotone in/decreasing, the spline also is monotone (CJC Kruger method) The x data has to be sorted ascending

Second derivative (curvature) is NOT necessarily continuous at knots to allow higher flexibility to reduce oscillations!Constrained Cubic Spline Interpolation for Chemical Engineering Applications by CJC Kruger

xData : Vector<float>
yData : Vector<float>

function value at x values

Returns: HermiteCoef

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.;6.;13.;13.1|]

 // get coefficients for piecewise interpolating cubic polynomials
 let coefficients = 
     CubicSpline.Hermite.interpolatePreserveMonotonicity xData yData

interpolateSorted xData yData

Full Usage: interpolateSorted xData yData

Parameters:
    xData : Vector<float> - Note: Must not contain duplicate x values (use Approximation.regularizeValues to preprocess data!)
    yData : Vector<float> - function value at x values

Returns: HermiteCoef Coefficients that define the interpolating function.

Computes coefficients for piecewise interpolating splines. The x data has to be sorted ascending.

Second derivative (curvature) is NOT necessarily continuous at knots to allow higher flexibility to reduce oscillations!

xData : Vector<float>

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

yData : Vector<float>

function value at x values

Returns: HermiteCoef

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 = 
     CubicSpline.Hermite.interpolateSorted xData yData

interpolateWithSlopes xData yData slopes

Full Usage: interpolateWithSlopes xData yData slopes

Parameters:
    xData : Vector<float> - Note: Must not contain duplicate x values (use Approximation.regularizeValues to preprocess data!)
    yData : Vector<float> - function value at x values
    slopes : Vector<float> - slopes at x values

Returns: HermiteCoef Coefficients that define the interpolating function.

Computes coefficients for piecewise interpolating splines. The x data has to be sorted ascending.

Second derivative (curvature) is NOT necessarily continuous at knots to allow higher flexibility to reduce oscillations!

xData : Vector<float>

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

yData : Vector<float>

function value at x values

slopes : Vector<float>

slopes at x values

Returns: HermiteCoef

Coefficients that define the interpolating function.

predict coef x

Full Usage: predict coef x

Parameters:
    coef : HermiteCoef
    x : 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.

x values outside of the xValue range are predicted by straight lines defined by the nearest knot!

coef : HermiteCoef
x : 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 = 
     CubicSpline.Hermite.interpolate xData yData

 // get interpolating function 
 let func = CubicSpline.Hermite.predict coefLinSpl

 // get function value at x=3.4
 func 3.4