DCG@k = Σ relᵢ / log₂(i + 1) over the top k positions, so a relevant item at position 1 counts fully, at position 3 half as much, and further down less and less. Dividing by the ideal DCG, the score of the best possible ordering of the same items, gives NDCG, comparable across queries with different numbers of relevant results. A common variant uses 2^relᵢ − 1 as the gain to stress highly relevant items. Järvelin and Kekäläinen introduced it in 2002.
Example: four results with graded relevance 3, 2, 1 and 0. In the ideal order the DCG is 3 + 2/log₂3 + 1/2 ≈ 4.76. Showing them as 2, 3, 1, 0 scores about 0.92, and the worst order, 0, 1, 2, 3, about 0.61. NDCG is gentler than you might expect, because the log discount falls slowly.
Related metrics: precision@k ignores order within the top k, mean reciprocal rank only looks at the first relevant result, and mean average precision needs binary relevance. NDCG's strength is graded relevance. Offline NDCG computed from click logs inherits the logs' position bias, so it doesn't always predict how a ranking does online.