## Class PolynomialsLeastSquaresFitter

• java.lang.Object
• com.opengamma.strata.math.impl.interpolation.PolynomialsLeastSquaresFitter

• public class PolynomialsLeastSquaresFitter
extends Object
Derive coefficients of n-degree polynomial that minimizes least squares error of fit by using QR decomposition and back substitution.
• ### Constructor Summary

Constructors
Constructor Description
PolynomialsLeastSquaresFitter()
• ### Method Summary

All Methods
Modifier and Type Method Description
LeastSquaresRegressionResult regress​(double[] xData, double[] yData, int degree)
Given a set of data (X_i, Y_i) and degrees of a polynomial, determines optimal coefficients of the polynomial.
PolynomialsLeastSquaresFitterResult regressVerbose​(double[] xData, double[] yData, int degree, boolean normalize)
Alternative regression method with different output.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### PolynomialsLeastSquaresFitter

public PolynomialsLeastSquaresFitter()
• ### Method Detail

• #### regress

public LeastSquaresRegressionResult regress​(double[] xData,
double[] yData,
int degree)
Given a set of data (X_i, Y_i) and degrees of a polynomial, determines optimal coefficients of the polynomial.
Parameters:
xData - X values of data
yData - Y values of data
degree - Degree of polynomial which fits the given data
Returns:
LeastSquaresRegressionResult Containing optimal coefficients of the polynomial and difference between yData[i] and f(xData[i]), where f() is the polynomial with the derived coefficients
• #### regressVerbose

public PolynomialsLeastSquaresFitterResult regressVerbose​(double[] xData,
double[] yData,
int degree,
boolean normalize)
Alternative regression method with different output.
Parameters:
xData - X values of data
yData - Y values of data
degree - Degree of polynomial which fits the given data
normalize - Normalize xData by mean and standard deviation if normalize == true
Returns:
PolynomialsLeastSquaresRegressionResult containing coefficients, rMatrix, degrees of freedom, norm of residuals, and mean, standard deviation