Returns the polynomial fit of polynomial order for a data set (X, Y) using the Least Square method.

![]() |
Coefficient Constraint specifies the constraints on polynomial coefficients of certain orders by setting the coefficient of a specified order to coefficient. Use Coefficient Constraint if you know the exact values of certain polynomial coefficients.
| ||||||||||||
![]() |
Y is the array of dependent values. The number of sample points in Y must be greater than polynomial order. If the number of sample points is less than or equal to polynomial order, this VI sets Polynomial Coefficients to an empty array and returns an error. | ||||||||||||
![]() |
X is the array of independent values. The number of sample points in X must be greater than polynomial order. If the number of sample points is less than or equal to polynomial order, this VI sets Polynomial Coefficients to an empty array and returns an error. | ||||||||||||
![]() |
Weight is the array of weights for the observations (X, Y). Weight must be the same size as Y. If Weight is unwired, the VI sets all elements of Weight to 1. If an element of Weight is less than 0, the VI uses the absolute value of the element. | ||||||||||||
![]() |
polynomial order specifies the order of the polynomial to fit to the data set. polynomial order must be greater than or equal to zero. If polynomial order is less than zero, this VI sets Polynomial Coefficients to an empty array and returns an error. This VI accepts polynomial order less than or equal to 25. If polynomial order is greater than 25, the VI sets the coefficients in Polynomial Coefficients to zero whose orders are greater than 25 and returns a warning. The default is 2. | ||||||||||||
![]() |
algorithm specifies the algorithm to use to compute the Best Polynomial Fit.
|
||||||||||||
![]() |
Best Polynomial Fit returns the y-values of the polynomial curve that best fits the input values. | ||||||||||||
![]() |
Polynomial Coefficients returns the coefficients of the fitted model in ascending order of power. The total number of elements in Polynomial Coefficients is m + 1, where m is the polynomial order. | ||||||||||||
![]() |
error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster. | ||||||||||||
![]() |
mse is the mean squared error. |
This VI fits data to a polynomial function of the general form described by the following equation:

where f represents the output sequence Best Polynomial Fit, x represents the input sequence X, a represents the Polynomial Coefficients, and m is the polynomial order.
The VI calculates mse using the following equation:

where y represents the input sequence Y, wi is Weight, and n is the number of data points.
In real application, polynomial order is less than 10. If you specify polynomial order as greater than 25, the VI sets the coefficients in Polynomial Coefficients to zero whose orders are greater than 25 and returns a warning.
Refer to the following VIs for examples of using the General Polynomial Fit VI: