question: double H ( ) { int [ ] n = new int [ numberOfGroups ] ; double [ ] rbar = new double [ numberOfGroups ] ; for ( RankedObservation observation : data ) { n [ observation . getGroup ( ) ] ++ ; rbar [ observation . getGroup ( ) ] += observation . getRank ( ) ; } double H = 0.0 ; for ( int i = 0 ; i < numberOfGroups ; i ++ ) { H += Math . pow ( rbar [ i ] , 2.0 ) / n [ i ] ; } int N = data . size ( ) ; return 12.0 / ( N * ( N + 1 ) ) * H - 3.0 * ( N + 1 ) ; }
target:  Computes the chi-squared approximation of the Kruskal-Wallis test statistic. See equation (22-1) in the reference book for details.