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)); }