How to use this calculator
Score a ranked result list using graded relevance, rank discounting, and an ideal-order normalization.
- Enter Relevance grades in ranked order, Cutoff k. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
How this calculation works
A ranking can place highly relevant items near the top or bury them below less useful results. NDCG@k makes that position matter while allowing multiple relevance grades, then scales the observed gain against the ideal ordering of the same judged items.
Inputs and units
relevanceGrades— Relevance grades in ranked order- Enter one nonnegative relevance grade per result, best rank first. Grades may be decimals from 0 to 20; separate values with commas or spaces.
cutoffK— Cutoff k- Number of top-ranked results to score. Must be a whole number no greater than the number of entered grades.
Formula
DCG@k = Σᵢ₌₁ᵏ (2ʳᵢ − 1) / log₂(i + 1); NDCG@k = DCG@k / IDCG@k, where IDCG sorts the entered relevance grades from highest to lowest.
Method
Enter nonnegative relevance grades in the order returned by the system, followed by cutoff k. This calculator uses exponential gain 2ʳ − 1 and logarithmic rank discount log₂(i + 1). It computes DCG for the supplied order, IDCG for the best order of the same grades, then divides the two.
Worked example
For relevance grades 3, 2, 3, 0, 1, 2 with k = 4, DCG@4 is about 12.3928 and the ideal DCG@4 is about 14.2085. NDCG@4 = 12.3928 / 14.2085 ≈ 0.8722.
Assumptions and limits
NDCG has multiple gain and discount conventions; this page uses the stated exponential-gain, log₂(i + 1) variant. Comparisons require the same relevance scale, judgments, and cutoff. If all grades are zero, the calculator reports 0 by convention; that case contains no positive relevance signal.
Frequently asked questions
What does an NDCG score of 1 mean?
The entered top-k results have the same relevance ordering as the ideal ordering under the chosen gain and discount convention.
Why does NDCG discount lower ranks?
A result near the top is usually examined before a result much farther down, so the formula gives earlier positions more weight.
How is NDCG different from average precision?
Average precision usually treats relevance as binary and summarizes precision at relevant ranks. NDCG can use graded relevance and explicitly discounts rank positions.
Can I compare NDCG values from different queries?
Only with care. Use comparable relevance scales, judging practices, and cutoffs; differing candidate sets or grade definitions can change the meaning of the score.
How do I use the Normalized Discounted Cumulative Gain (NDCG@k) Calculator?
Enter Relevance grades in ranked order, Cutoff k. Match the units shown beside each field and review the result together with the assumptions below.
Reference: Järvelin and Kekäläinen original discounted cumulative gain paper. See our calculation methodology.