Accord.Statistics.Distributions.Univariate.KolmogorovSmirnovDistribution.computeH C# (CSharp) Method

computeH() private static method

Computes matrix H of the Pomeranz algorithm.
private static computeH ( int n, double A, double H ) : double
n int
A double
H double
return double
        private static double computeH(int n, double[] A, double[][] H)
        {
            // Precomputes H[][] = (A[j] - A[j-1]^k / k!

            double w;
            H[0][0] = 1;
            w = 2.0 * A[2] / n;
            for (int j = 1; j <= n + 1; j++)
                H[0][j] = w * H[0][j - 1] / j;

            H[1][0] = 1;
            w = (1.0 - 2.0 * A[2]) / n;
            for (int j = 1; j <= n + 1; j++)
                H[1][j] = w * H[1][j - 1] / j;

            H[2][0] = 1;
            w = A[2] / n;
            for (int j = 1; j <= n + 1; j++)
                H[2][j] = w * H[2][j - 1] / j;

            H[3][0] = 1;
            for (int j = 1; j <= n + 1; j++)
                H[3][j] = 0;
            return w;
        }
        #endregion