DCG adds up gains, and lower ranks count for less
Grading a ranked list needs two ideas: how much each result is worth, and how much its position counts.
A better grade is worth much more
Results get grades from human judges or from what users did. A common scale runs from 0 to 3, where 3 is exactly right and 0 is wrong.
The gain turns a grade into points. With the points roughly double with each grade, so one perfect result beats several decent ones.
Each rank down counts a little less
| Rank | Weight 1 / log2(rank + 1) | Weight 1 / rank |
|---|---|---|
| 1 | 1.00 | 1.00 |
| 2 | 0.63 | 0.50 |
| 3 | 0.50 | 0.33 |
| 4 | 0.43 | 0.25 |
| 5 | 0.39 | 0.20 |
| 10 | 0.29 | 0.10 |
A result further down is worth less, because the user is less likely to ever look at it. The discount says how much less. DCG divides each gain by , so each rank keeps a weight of one over that: the left column.
The weight falls fast at first, then flattens. Rank 2 keeps 63% of its gain, and rank 10 still keeps 29%.
That's on purpose. Järvelin and Kekäläinen, who defined these measures in a 2002 paper on cumulated gain, wanted a discount that falls, but not as steeply as dividing by the rank. Users do keep reading. Dividing by the rank, the right column, would leave rank 10 with 10%.
In the editor, write gains(grades): the gain 2^grade - 1 of every grade. Then write weights(n): the weight 1 / log2(rank + 1) that each rank from 1 to n keeps. Both return NumPy arrays.