Accord.Tests.Statistics.LogisticGradientDescentTest.finiteDifferences C# (CSharp) Method

finiteDifferences() private static method

private static finiteDifferences ( double input, double output, bool stochastic ) : double[]
input double
output double
stochastic bool
return double[]
        private static double[] finiteDifferences(double[][] input, double[] output, bool stochastic)
        {
            var regression = new LogisticRegression(inputs: 2);
            var diff = new FiniteDifferences(3);

            diff.Function = (x) =>
            {
                for (int i = 0; i < x.Length; i++)
                    regression.SetCoefficient(i, x[i]);

                return regression.GetLogLikelihood(input, output);
            };

            return diff.Compute(regression.Coefficients);
        }