question: public double deviation ( double [ ] [ ] samples ) { final int N = totalLength ( samples ) ; final double A2 = unstandardized ( samples , N ) ; final int k = samples . length ; double H = 0. ; for ( double [ ] sample : samples ) { H += 1. / sample . length ; } double g = 0. , h = 1. / ( N - 1 ) ; for ( int i = N - 2 ; i > 0 ; i -- ) { g += h / ( N - i ) ; h += 1. / i ; } final int k2 = k * k ; final double hk = h * k ; final double a = ( 4 * g - 6 ) * ( k - 1 ) + ( 10 - 6 * g ) * H ; final double b = ( 2 * g - 4 ) * k2 + 8 * hk + ( 2 * g - 14 * h - 4 ) * H - 8 * h + 4 * g - 6 ; final double c = ( 6 * h + 2 * g - 2 ) * k2 + ( 4 * h - 4 * g + 6 ) * k + ( 2 * h - 6 ) * H + 4 * h ; final double d = ( 2 * h + 6 ) * k2 - 4 * hk ; final double N2 = N * N , N3 = N2 * N ; final double sigmasq = ( a * N3 + b * N2 + c * N + d ) / ( ( N - 1. ) * ( N - 2. ) * ( N - 3. ) ) ; return sigmasq > 0 ? ( A2 - ( k - 1 ) ) / Math . sqrt ( sigmasq ) : 0. ; }
target:  K-samples version of the Anderson-Darling test.