- Introduced by
- Kalervo Järvelin & Jaana Kekäläinen
- Year
- 2002
- Type
- Graded-relevance ranking-evaluation pipeline with position discounting and normalization
- Family
- Information-retrieval evaluation / ranking metrics
What does it do?
Normalized Discounted Cumulative Gain (nDCG) is a metric for evaluating ranked retrieval and recommendation when relevance is graded rather than simply relevant or not.
It builds on the cumulated gain measures proposed by Kalervo Järvelin and Jaana Kekäläinen in their 2002 ACM Transactions on Information Systems paper: cumulated gain over graded relevance, a discounted variant that devalues late-retrieved documents, and a performance measure relative to the ideal ranking. nDCG is the standardized form of these ideas. It accumulates the graded gain of each item, discounts that gain by rank, and normalizes the total against the best possible ordering, giving scores between 0 and 1 that can be compared across queries.
The intuition behind the method
Suppose a search returns ten papers and you have judged each as not relevant, somewhat relevant, or highly relevant. A good evaluation metric should capture two things people intuitively care about. First, finding a highly relevant paper is worth more than finding a marginally relevant one — relevance has degrees, not just yes or no. Second, position matters: a great result at rank 1 is far more useful than the same result buried at rank 9, because users read from the top and rarely scroll. nDCG encodes both ideas. It assigns each result a 'gain' based on its relevance grade, then 'discounts' that gain the further down the list it appears, using a logarithm so the penalty grows gently. Summing these discounted gains gives a raw quality score, but raw scores are hard to compare across queries that have different numbers of relevant documents. So nDCG divides by the score of the ideal ranking — what you would get if every document were sorted perfectly by relevance — yielding a clean number between 0 and 1, where 1 means the system produced the best possible order.
History
The measure traces to the 2002 ACM TOIS paper by Kalervo Järvelin and Jaana Kekäläinen, 'Cumulated gain-based evaluation of IR techniques'. That paper proposed cumulated gain measures for graded relevance judgments, a discounted variant that devalues late-retrieved documents, and a measure of performance relative to the ideal ranking, which is the basis of the normalization in nDCG. The authors demonstrated these measures on TREC-7 data with 20 queries and a four-point relevance scale. The specific gain and discount formulas now common in practice are later conventions built on these ideas.
When to use it
Use nDCG whenever you evaluate a ranked list and relevance is naturally graded rather than binary, and where the position of good results matters: web and academic search evaluation, recommender-system ranking, learning-to-rank model selection, and any retrieval task with multi-level relevance judgments. It is the right choice when you want a single rank-sensitive number per query that is comparable across queries with different numbers of relevant items, and when top-of-list quality is what users experience. nDCG is less appropriate when you only have binary relevance and care about recall over the whole list (where MAP is more natural), or when relevance judgments are too sparse or noisy to support fine grades. Fix the cutoff k and the gain and discount conventions, because differing conventions make reported values incomparable. Queries with no relevant documents give IDCG = 0 and an undefined nDCG, so exclude them or apply an explicit convention (for example, scoring them 0) and report it with the results.
Limitations and considerations
- Requires graded relevance judgments, which are more expensive and more subjective to collect than binary labels.
- Sensitive to the choice of gain function and log base; the exponential 2^rel - 1 gain and base-2 discount are conventions, and alternatives change scores.
- With incomplete judgments, unjudged documents are often treated as non-relevant, which can bias the metric against systems that surface novel relevant items.
- A single cutoff k can hide differences below it, and IDCG can be ill-defined for queries with no relevant documents.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Handles multi-level (graded) relevance, rewarding highly relevant results more than marginally relevant ones.
- Rank-sensitive: the logarithmic discount strongly rewards placing the best results at the top of the list.
- Normalization by the ideal ranking yields a 0-to-1 score that is comparable and averageable across queries with different relevance pools.
- Widely implemented in evaluation toolkits, so results computed with matching settings can be compared directly with other reports.
Applications
- Evaluating and comparing search-engine and academic-search ranking quality with graded relevance.
- Selecting and tuning learning-to-rank models, where nDCG is a standard optimization target and reporting metric.
- Assessing recommender systems whose item relevance comes in degrees of user preference.
- Benchmarking neural and lexical rankers on graded-relevance test collections, such as TREC collections.
- Comparing first-stage and re-ranking stages of a retrieval pipeline by nDCG@k at a fixed cutoff.
How it works
How it works
The pipeline starts from graded relevance judgments, which use several levels instead of a single relevant/non-relevant label. The example scale on this page runs from 0 (not relevant) to 3 (highly relevant), with intermediate grades in between. Järvelin and Kekäläinen motivate graded judgments by the need to identify highly relevant documents and rank them first, since not all documents are equally relevant. Their case study used a four-point scale. Each item at rank i receives its grade rel_i, and these grades feed every later gain calculation.
Formula
rel_i \in \{0, 1, 2, \dots, g\},\quad i = 1, \dots, pNext, a position discount reduces the value of relevant items found lower in the list. The 2002 paper proposes a discount factor that devalues late-retrieved documents; its abstract does not give the exact formula. The widely used later convention divides each item's gain by the base-2 logarithm of its rank plus one. The discount at rank 1 is 1, while at rank 2 it is 1/log2(3), so moving from rank 1 to rank 2 already lowers the weight noticeably. The reduction per position shrinks further down the list because the logarithm grows slowly. The base 2 is a convention: a different base changes how steeply the discount falls.
Formula
\mathrm{disc}(i) = \frac{1}{\log_2(i + 1)},\qquad i \ge 1The discounted cumulative gain (DCG) at cutoff k is computed by summing, over the top k results, each item's gain divided by its position discount. A common formulation, used on this page, sets the gain to 2^rel - 1, which sharply rewards higher grades, and divides by the logarithmic discount. This exponential gain is a later convention, not something specified in the 2002 abstract. Other references use a linear gain equal to the grade. For example, Shalev-Shwartz and Ben-David define NDCG with linear gain y_i and a discount 1/log2(r-i+2) that is truncated to the top-k positions. DCG@k grows when relevant items are both highly relevant and placed near the top. Always state the gain function, log base and k with the results.
Formula
\mathrm{DCG}@k = \sum_{i=1}^{k} \frac{2^{rel_i} - 1}{\log_2(i + 1)}Because DCG depends on how many relevant documents exist and how relevant they are, its raw value is not comparable across queries. To fix this, the ideal DCG (IDCG) is computed: the same DCG formula applied to the perfect ranking, obtained by sorting all judged items in descending order of relevance grade and taking the top k. IDCG@k is the maximum DCG achievable for that query given its judgments, and serves as the per-query upper bound. If a query has no relevant documents, IDCG is 0 and nDCG is undefined.
Formula
\mathrm{IDCG}@k = \sum_{i=1}^{k} \frac{2^{rel_i^{*}} - 1}{\log_2(i + 1)},\quad rel^{*} = \mathrm{sort}_{\downarrow}(rel)Finally, nDCG@k is obtained by dividing the system's DCG@k by the ideal IDCG@k. This normalization rescales the measure into the interval from 0 to 1, where 1 means the system reproduced the ideal ordering and lower values quantify how far short it fell. Because every query is normalized by its own ideal, nDCG values are comparable and can be averaged across a query set to summarize a system's overall ranking effectiveness.
Formula
\mathrm{nDCG}@k = \frac{\mathrm{DCG}@k}{\mathrm{IDCG}@k} \in [0, 1]Common pitfalls
- Comparing nDCG values computed with different gain functions (linear versus 2^rel - 1), log bases, or cutoffs k as if they were on the same scale.
- Forgetting to normalize and reporting raw DCG, which is not comparable across queries with different numbers of relevant items.
- Treating all unjudged documents as non-relevant without acknowledging the pooling bias this introduces in incomplete test collections.
- Choosing a cutoff k smaller than the number of relevant documents and then concluding a system is poor when it simply ranked relevant items just below k.
- Silently averaging over queries with IDCG = 0, or dropping them without saying so; the handling of such queries changes the mean.
Frequently asked questions
Why normalize DCG instead of just reporting DCG?
Raw DCG depends on how many relevant documents a query has and how relevant they are, so DCG values are not comparable across queries — a query with many highly relevant documents can produce a large DCG even from a mediocre ranking. Dividing by the ideal DCG (the best achievable ordering for that query) rescales every query to a 0-to-1 range, where 1 is the perfect ranking. This makes nDCG comparable across queries and meaningful to average over a query set. Queries with no relevant documents have IDCG = 0 and need an explicit convention.
Which gain and discount formula should I use?
Two conventions are common: a linear gain equal to the relevance grade, and an exponential gain of 2^rel - 1 that more sharply rewards higher grades, both divided by a base-2 logarithmic discount of (rank + 1). Machine-learning texts such as Shalev-Shwartz and Ben-David use a linear gain with a log2 discount truncated at top-k. The exponential form is widely used in web-search and learning-to-rank work. The key practical rule is to fix one convention, apply it consistently, and report the gain function, log base and k, because values computed under different choices are not directly comparable.
How does nDCG differ from Mean Average Precision (MAP)?
MAP is built for binary relevance and rewards a system for ranking all relevant documents highly across the full list, averaging precision at each relevant retrieval. nDCG is built for graded relevance and is typically reported at a top cutoff k, emphasizing that the most relevant items belong at the very top. Use MAP when relevance is binary and overall ranking of all relevant documents matters; use nDCG when relevance has degrees and top-of-list quality is the priority.
Related methods
Sources
Järvelin, K., & Kekäläinen, J. (2002). Cumulated gain-based evaluation of IR techniques. ACM Transactions on Information Systems, 20(4), 422-446.
Open DOI referenceUnderstanding Machine Learning: From Theory to Algorithms, p. 240