Calculator Inputs
Use comma, space, newline, or semicolon separators. Negative values are clamped to zero.
Example Data Table
This sample query shows graded labels for a ranked list before ideal sorting.
| Position | Document ID | Observed Relevance | Exponential Gain | Linear Gain |
|---|---|---|---|---|
| 1 | D101 | 3 | 7 | 3 |
| 2 | D087 | 2 | 3 | 2 |
| 3 | D044 | 3 | 7 | 3 |
| 4 | D212 | 0 | 0 | 0 |
| 5 | D119 | 1 | 1 | 1 |
| 6 | D302 | 2 | 3 | 2 |
Formula Used
1) Gain Function
Exponential gain: Gain(rel) = 2rel − 1
Linear gain: Gain(rel) = rel
2) Discounted Cumulative Gain
DCG@k = Σ from i = 1 to k of ( Gain(reli) / logb(i + 1) )
3) Ideal Discounted Cumulative Gain
iDCG@k is computed by sorting judged relevance values in descending order, then applying the same discount rule across the top k positions.
4) Normalized DCG
nDCG@k = DCG@k / iDCG@k, provided iDCG@k is greater than zero.
How to Use This Calculator
- Enter the observed relevance grades in the order produced by your ranking model.
- Set the cutoff k for the evaluation depth you want to study.
- Choose exponential gain for stronger emphasis on highly relevant items, or linear gain for proportional treatment.
- Set the log base. Base 2 is the most common ranking evaluation choice.
- Optionally provide a custom judged relevance pool when the ideal list should come from independent labels rather than the observed ranking.
- Press Calculate Ideal DCG to display the result above the form.
- Review the summary cards, detailed position table, and Plotly chart.
- Use the CSV and PDF buttons to export the breakdown for reports, audits, or experiment tracking.
Frequently Asked Questions
1. What does ideal DCG measure?
Ideal DCG measures the maximum discounted gain possible for a query when the most relevant items are placed in the best positions first.
2. Why is discounting needed?
Discounting reduces the contribution of lower-ranked items, reflecting the fact that users usually pay more attention to results near the top.
3. When should I use exponential gain?
Use exponential gain when highly relevant items deserve much stronger reward than moderately relevant ones. It is common in search evaluation.
4. What is the role of cutoff k?
Cutoff k limits evaluation depth. Smaller values focus on early precision, while larger values capture broader ranking quality across more positions.
5. Can I calculate nDCG here too?
Yes. The tool reports DCG, ideal DCG, and normalized DCG, so you can compare actual ranking quality against the best possible ordering.
6. What if I leave the custom judged pool empty?
The calculator will sort the observed relevance scores in descending order and use that list to create the ideal ranking automatically.
7. Can relevance grades be decimals?
Yes. Decimal relevance values are accepted, which is useful when labels come from averaged judgments or scaled scoring frameworks.
8. Why might my nDCG be low?
Low nDCG usually means strong relevance appears too late, weak results appear too early, or the ranking misses highly relevant items entirely.