protected static <A> double[] ranks(final NumberArrayAdapter<?, A> adapter, final A data, int[] idx) {
    final int len = idx.length;
    double[] ret = new double[len];
    for(int i = 0; i < len;) {
      final int start = i++;
      final double val = adapter.getDouble(data, idx[start]);
      // Include ties:
      while(i < len && adapter.getDouble(data, idx[i]) <= val) {
        i++;
      }
      final double score = (start + i - 1) * .5 + 1;
      for(int j = start; j < i; j++) {
        ret[idx[j]] = score;
      }
    }
    return ret;
  }
protected static < A > double [ ] ranks ( final NumberArrayAdapter < ? , A > adapter , final A data , int [ ] idx ) { final int len = idx . length ; double [ ] ret = new double [ len ] ; for ( int i = 0 ; i < len ; ) { final int start = i ++ ; final double val = adapter . getDouble ( data , idx [ start ] ) ; while ( i < len && adapter . getDouble ( data , idx [ i ] ) <= val ) { i ++ ; } final double score = ( start + i - 1 ) * .5 + 1 ; for ( int j = start ; j < i ; j ++ ) { ret [ idx [ j ] ] = score ; } } return ret ; }
Compute ranks of all objects, ranging from 1 to len.

Ties are given the average rank.

@param adapter Data adapter
@param data Data array
@param idx Data index
@return Array of scores