kroghInterpolateFit#

swordfish.function.kroghInterpolateFit()#

This function performs polynomial interpolation for a given set of points, ensuring the polynomial passes through all points in the set.

Multiple derivative values at each point of X can be specified by repeating X values and assigning corresponding derivative values as consecutive Y values:

  • If an X value appears only once, the corresponding Y is the value of the polynomial f(X).

  • If an X value appears multiple times, the first Y is the value of f(X), the second Y is the first derivative f’(X), the third Y is the second derivative f’’(X), and so on. For example, with inputs X=[0,0,1,1] and Y=[1,0,2,3], the interpretation is Y[0]=f(0), Y[1]=f’(0), Y[2]=f(1), Y[3]=f’(1).

Parameters:
  • X (Constant) – A a numeric vector representing the x-coordinates of the points to be interpolated. Values in X must be in increasing order. Null values are not allowed.

  • Y (Constant) – A numeric vector of the same length as X, representing the y-coordinates of the points. Null values are not allowed.

  • der (Constant, optional) – A non-negative integer representing the derivative order to compute. The default value is 0, meaning to compute the polynomial’s value.

Returns:

A dictionary with the following keys:

  • modelName: A string “kroghInterpolate” indicating the model name.

  • X: The numeric vector representing the x-coordinates used for interpolation (i.e., the input X).

  • der: The non-negative integer representing the derivative order (i.e., the input der).

  • coeffs: A numeric vector containing the polynomial coefficients fitted from the input data points.

  • predict: The prediction function of the model. You can call model.predict(X) or predict(model, X) to make predictions with the generated model. It takes the following parameters:

  • model: A dictionary, which is the output of kroghInterpolateFit.

  • X: A numeric vector representing the x-coordinates at which to evaluate the polynomial.

Return type:

Constant