protected static <A, B> double[] computeBivariateRanks(NumberArrayAdapter<?, A> adapter1, A data1, NumberArrayAdapter<?, B> adapter2, B data2, int len) {
    double[] ret = new double[len];
    for(int i = 0; i < len; i++) {
      for(int j = i + 1; j < len; j++) {
        double xi = adapter1.getDouble(data1, i),
            xj = adapter1.getDouble(data1, j);
        double yi = adapter2.getDouble(data2, i),
            yj = adapter2.getDouble(data2, j);
        if(xi < xj) {
          ret[j] += (yi < yj) ? 1 : (yi == yj) ? .5 : 0;
        }
        else if(xj < xi) {
          ret[i] += (yj < yi) ? 1 : (yj == yi) ? .5 : 0;
        }
        else { // tied on x
          if(yi < yj) {
            ret[j] += .5;
          }
          else if(yj < yi) {
            ret[i] += .5;
          }
          else { // Double tied
            ret[i] += .25;
            ret[j] += .25;
          }
        }
      }
    }
    return ret;
  }
protected static < A , B > double [ ] computeBivariateRanks ( NumberArrayAdapter < ? , A > adapter1 , A data1 , NumberArrayAdapter < ? , B > adapter2 , B data2 , int len ) { double [ ] ret = new double [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j = i + 1 ; j < len ; j ++ ) { double xi = adapter1 . getDouble ( data1 , i ) , xj = adapter1 . getDouble ( data1 , j ) ; double yi = adapter2 . getDouble ( data2 , i ) , yj = adapter2 . getDouble ( data2 , j ) ; if ( xi < xj ) { ret [ j ] += ( yi < yj ) ? 1 : ( yi == yj ) ? .5 : 0 ; } else if ( xj < xi ) { ret [ i ] += ( yj < yi ) ? 1 : ( yj == yi ) ? .5 : 0 ; } else { if ( yi < yj ) { ret [ j ] += .5 ; } else if ( yj < yi ) { ret [ i ] += .5 ; } else { ret [ i ] += .25 ; ret [ j ] += .25 ; } } } } return ret ; }
Compute bivariate ranks.
<p>
q[i] is the number of objects such that x[j] &lt; x[i] and y[j] &lt; y[i]

@param adapter1 First adapter
@param data1 First data set
@param adapter2 Second adapter
@param data2 Second data set
@param len Length
@return Bivariate rank statistics.