コード例 #1
0
        ///
        /// <param name="xDataMatrix">  the x-matrix </param>
        /// <param name="betas"> Optimal coefficients of the polynomial </param>
        /// <param name="yDataVector">  the y-vlaues </param>
        /// <returns> Difference between yData[i] and f(xData[i]), where f() is the polynomial with derived coefficients </returns>
        private double[] residualsSolver(DoubleMatrix xDataMatrix, double[] betas, DoubleArray yDataVector)
        {
            DoubleArray betasVector = DoubleArray.copyOf(betas);

            DoubleArray modelValuesVector = (DoubleArray)OG_ALGEBRA.multiply(xDataMatrix, betasVector);
            DoubleArray res = (DoubleArray)OG_ALGEBRA.subtract(yDataVector, modelValuesVector);

            return(res.toArray());
        }
コード例 #2
0
        public virtual DoubleMatrix getUpdatedMatrix(System.Func <DoubleArray, DoubleMatrix> j, DoubleArray x, DoubleArray deltaX, DoubleArray deltaY, DoubleMatrix matrix)
        {
            ArgChecker.notNull(deltaX, "deltaX");
            ArgChecker.notNull(deltaY, "deltaY");
            ArgChecker.notNull(matrix, "matrix");
            double length2 = OG_ALGEBRA.getInnerProduct(deltaX, deltaX);

            if (length2 == 0.0)
            {
                return(matrix);
            }
            Matrix temp = OG_ALGEBRA.subtract(deltaY, OG_ALGEBRA.multiply(matrix, deltaX));

            temp = OG_ALGEBRA.scale(temp, 1.0 / length2);
            return((DoubleMatrix)OG_ALGEBRA.add(matrix, OG_ALGEBRA.getOuterProduct(temp, deltaX)));
        }