static LeastSquaresRegressionResultTest()
        {
            const int n = 100;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[][] x = new double[n][2];
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: double[][] x = new double[n][2];
            double[][] x = RectangularArrays.ReturnRectangularDoubleArray(n, 2);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] y1 = new double[n];
            double[] y1 = new double[n];
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final double[] y2 = new double[n];
            double[] y2 = new double[n];
            for (int i = 0; i < n; i++)
            {
                x[i][0] = RANDOM.NextDouble();
                x[i][1] = RANDOM.NextDouble();
                y1[i]   = F1.applyAsDouble(x[i][0], x[i][1]);
                y2[i]   = F2.applyAsDouble(x[i][0], x[i][1]);
            }
            NO_INTERCEPT = REGRESSION.regress(x, null, y1, false);
            INTERCEPT    = REGRESSION.regress(x, null, y2, true);
        }
Exemple #2
0
        /// <summary>
        /// {@inheritDoc}
        /// </summary>
        public virtual GaussianQuadratureData generate(int n)
        {
            ArgChecker.isTrue(n > 0);
            Pair <DoubleFunction1D, DoubleFunction1D>[] polynomials = LAGUERRE.getPolynomialsAndFirstDerivative(n, _alpha);
            Pair <DoubleFunction1D, DoubleFunction1D>   pair        = polynomials[n];
            DoubleFunction1D p1         = polynomials[n - 1].First;
            DoubleFunction1D function   = pair.First;
            DoubleFunction1D derivative = pair.Second;

            double[] x    = new double[n];
            double[] w    = new double[n];
            double   root = 0;

            for (int i = 0; i < n; i++)
            {
                root = ROOT_FINDER.getRoot(function, derivative, getInitialRootGuess(root, i, n, x)).Value;
                x[i] = root;
                w[i] = -GAMMA_FUNCTION.applyAsDouble(_alpha + n) / CombinatoricsUtils.factorialDouble(n) / (derivative.applyAsDouble(root) * p1.applyAsDouble(root));
            }
            return(new GaussianQuadratureData(x, w));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void test()
        public virtual void test()
        {
            assertEquals(F.applyAsDouble(SIGMA, T), 0.4560, 1e-4);
        }