code: protected double computeDCG(final double rel, final int rank) {
          double dcg = 0.0;
          if (rel >= getRelevanceThreshold()) {
              switch (type) {
                  default:
                  case EXP:
                      dcg = (Math.pow(2.0, rel) - 1.0) / (Math.log(rank + 1) / Math.log(2));
                      break;
                  case LIN:
                      dcg = rel;
                      if (rank > 1) {
                          dcg /= (Math.log(rank) / Math.log(2));
                      }
                      break;
                  case TREC_EVAL:
                      dcg = rel / (Math.log(rank + 1) / Math.log(2));
                      break;
              }
          }
          return dcg;
      }
docs: Method that computes the discounted cumulative gain of a specific item,
  taking into account its ranking in a user's list and its relevance value.
  
  @param rel the item's relevance
  @param rank the item's rank in a user's list (sorted by predicted rating)
  @return the dcg of the item