cubicSpline#

swordfish.function.cubicSpline()#

Cubic spline data interpolator.

Parameters:
  • x (Constant) – A numeric vector containing values of the independent variable. The length of x must be no smaller than 3. Its values must be real and in strictly increasing order.

  • y (Constant) – A numeric vector containing values of the dependent variable. The length of y must match the length of x.

  • bc_type (Constant) –

    A STRING scalar, pair, or a vector of length no greater than 2. It specifies the boundary condition type.

    • If bc_type is a string or a vector of length 1, the specified condition will be applied at both ends of a spline.

    • If bc_type is a pair or a vector of length 2, the first and the second value will be applied at the curve start and end respectively.

    Its value can be:

    • ”not-a-knot” (default): The first and second segment at a curve end are the same polynomial.

    • ”clamped”: The first derivative at curves ends are zero.

    • ”natural”: The second derivative at curve ends are zero.

Returns:

A dictionary withthe following keys:

  • c: Coefficients of the polynomials on each segment.

  • x: Breakpoints. The input x.

  • predict: A prediction function of the model, which returns the cubic spline interpolation result at point X. It can be called using model.predict(X) or predict(model, X), where

    • model: A dictionary indicating the output of cubicSpline.

    • X: A numeric vector indicating the X-coordinate of the point to be queried.

  • modelName: A string indicating the model name, which is “cubicSpline”.

Return type:

Constant