linearInterpolateFit#
- swordfish.function.linearInterpolateFit()#
Perform linear interpolation/extrapolation on a set of points. Interpolation estimates unknown values that fall between known data points, while extrapolation estimates values beyond the existing data range.
- Parameters:
X (Constant) – A numeric vector indicating the x-coordinates of the points for interpolation. Note that X must contain no less than two unique values with no null values.
Y (Constant) – A numeric vector indicating the y-coordinates of the points for interpolation. Note that Y must be of the same length as X with no null values.
fillValue (Constant, optional) –
Specifies how to assign values for the x-coordinate of the points outside the existing data range. The following options are supported:
A numeric pair in the form (min, max), where min and max represent the values assigned when the x-coordinate of the point Xnew is smaller than the minimum of X or larger than the maximum of X, respectively. Specifically:
If Xnew < Xmin, it is assigned below.
If Xnew > Xmax, it is assigned above.
The string “extrapolate” (default), which indicates that extrapolation is performed.
sorted (Constant, optional) –
A Boolean scalar indicating whether the input X is sorted in ascending order.
If set to true, X must be in ascending order.
If set to false (default), the function will sort X and adjust the order of Y accordingly.
- Returns:
A dictionary containing the following keys:
modelName: A string indicating the model name, which is “linearInterpolate”.
sortedX: A DOUBLE vector indicating the input Xsorted in ascending order.
sortedY: A DOUBLE vector indicating the input Y sorted corresponding to sortedX.
fillValue: The input fillValue.
predict: The prediction function of the model, which returns linear interpolation results. It can be called using model.predict(X) or predict(model, X), where:
model: A dictionary indicating the output of linearInterpolateFit.
X: A numeric vector indicating the x-coordinates of the points to be predicted.
- Return type: