import math


def dcg_trec(r, k=None):
    """The `trec_eval` version of DCG

    :param r: results
    :param k: cut-off
    :return: sum rel_i / log(i + 2)
    """
    result = sum([rel / math.log(rank + 2, 2) for rank, rel in enumerate(r[:k])])
    return result