Skip to content
ENExplore Calculators

NDCG Calculator

Calculate Normalized Discounted Cumulative Gain to evaluate ranking model quality.

About NDCG Calculator

NDCG measures ranking quality by comparing a predicted ranking's Discounted Cumulative Gain (DCG) against the ideal ranking (IDCG). DCG gives higher weight to relevant items appearing earlier in the ranking, using a logarithmic discount. NDCG = DCG / IDCG normalizes to [0, 1].

Formula

NDCG

NDCG = DCG / IDCG; DCG = sum((2^rel_i - 1) / log2(i + 2))

rel_i
Relevance score of item at position i
IDCG
DCG of the ideal (perfectly sorted) ranking

Worked example

With the default values below, NDCG Calculator returns NDCG of 0.9488. Change any input above and every figure here is recalculated in your browser.

Inputs used

Predicted Ranking Relevance
3, 2, 3, 0, 1, 2
Ideal Ranking Relevance
3, 3, 2, 2, 1, 0

Results

NDCG
0.9488
DCG
13.8483
IDCG
14.5954

Step by step

  1. 1DCG: Σ(2^rel_i − 1) / log₂(i+2)= 13.848264
  2. 2IDCG: same formula with ideal ordering= 14.595391
  3. 3NDCG = DCG / IDCG= 0.948811

Assumptions and limits

  • The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Why use logarithmic discounting?

Users are much more likely to look at top-ranked results. The log discount reflects diminishing returns of later positions — a relevant result at position 1 is far more valuable than the same result at position 10.

When is NDCG preferred over precision@k?

NDCG is preferred when relevance is graded (not binary) and position matters. It captures both the relevance level and rank position, while precision@k only counts binary relevant/irrelevant.

NDCG Calculator – Calculate NDCG & DCG | Calcrivo