/// <summary> /// This regression method is private and called in other regression methods </summary> /// <param name="xDataMatrix"> _nData x (_degree + 1) matrix whose low vector is (xData[i]^0, xData[i]^1, ..., xData[i]^{_degree}) </param> /// <param name="yDataVector"> the y-values </param> /// <param name="nData"> Number of data points </param> /// <param name="degree"> the degree </param> private LeastSquaresRegressionResult regress(DoubleMatrix xDataMatrix, DoubleArray yDataVector, int nData, int degree) { Decomposition <QRDecompositionResult> qrComm = new QRDecompositionCommons(); DecompositionResult decompResult = qrComm.apply(xDataMatrix); _qrResult = (QRDecompositionResult)decompResult; DoubleMatrix qMatrix = _qrResult.Q; DoubleMatrix rMatrix = _qrResult.R; double[] betas = backSubstitution(qMatrix, rMatrix, yDataVector, degree); double[] residuals = residualsSolver(xDataMatrix, betas, yDataVector); for (int i = 0; i < degree + 1; ++i) { ArgChecker.isFalse(double.IsNaN(betas[i]), "Input is too large or small"); } for (int i = 0; i < nData; ++i) { ArgChecker.isFalse(double.IsNaN(residuals[i]), "Input is too large or small"); } return(new LeastSquaresRegressionResult(betas, residuals, 0.0, null, 0.0, 0.0, null, null, true)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testRecoverOrginal() public virtual void testRecoverOrginal() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final com.opengamma.strata.math.linearalgebra.DecompositionResult result = QR.apply(A); DecompositionResult result = QR.apply(A); assertTrue(result is QRDecompositionResult); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final QRDecompositionResult qr = (QRDecompositionResult) result; QRDecompositionResult qr = (QRDecompositionResult)result; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final com.opengamma.strata.collect.array.DoubleMatrix q = qr.getQ(); DoubleMatrix q = qr.Q; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final com.opengamma.strata.collect.array.DoubleMatrix r = qr.getR(); DoubleMatrix r = qr.R; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final com.opengamma.strata.collect.array.DoubleMatrix a = (com.opengamma.strata.collect.array.DoubleMatrix) ALGEBRA.multiply(q, r); DoubleMatrix a = (DoubleMatrix)ALGEBRA.multiply(q, r); checkEquals(A, a); }