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

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 ) ; }
computes the chi - squared approximation of the kruskal - wallis test statistic . see equation ( 22 - 1 ) in the reference book for details .
