Average precision (AP) averages the precision at the rank of each relevant document over all $R$ relevant documents, a missed one counting zero, and mean average precision (MAP) is its mean over queries. The worked ranking (relevant at ranks 1, 3, 6 and 9, a fifth never retrieved) has AP 0.522, not the 0.653 of dividing by the four retrieved. AP is exactly the area of the uninterpolated precision-recall steps. It is top-heavy: moving the $j$-th relevant document up from rank $k$ to $k - 1$ adds $j/(Rk(k-1))$. For BM25 on Cranfield's 225 queries, MAP is 0.307 and the median AP 0.250. GMAP, the geometric mean, is about half of MAP there and weighs hard queries more. AP assumes binary relevance and complete judgments.
The worked ranking of evaluating ranked results has relevant documents at ranks 1, 3, 6 and 9, and misses a fifth. Its P@5 is 0.4, its R-precision is 0.4, and its 11-point average is 0.566. Each of these looks at one cutoff, or at eleven numbers. This article defines a single number that summarizes the whole ranking, rewarding the system both for finding every relevant document and for finding each one early.
Mean average precision (MAP) is the standard such number. For each query it summarizes the whole ranking in one number, average precision (AP), and it averages that number across queries. MAP sits between precision at a fixed cutoff, which answers a narrow question, and a precision-recall curve, which answers a broad one in too many numbers. It was the principal measure in TREC's ad hoc evaluations for many years, and it remains one of the most widely reported measures in the literature (Manning, Raghavan, and Schütze, 2008, §8.4).
Here is the route. First we compute AP for the worked ranking and see it as an area. Then we average it over queries, including Cranfield's 225. Next we derive why AP is top-heavy. Finally we look at its weaknesses and at the geometric mean, which favors hard queries.
The numbers in this article are computed by tools/experiments/eval_measures/worked_examples.py and cranfield_measures.py in the site's repository and rounded to three decimals.
Average precision for one query
Here is the idea in one sentence: stop at each relevant document, note the precision there, and average those precisions over all the relevant documents, counting a missed one as zero.
For a single query with $R$ relevant documents, average precision is the average, over the relevant documents, of the precision at the rank where each one is retrieved. A relevant document that is never retrieved contributes a precision of zero. Writing $k_j$ for the rank of the $j$-th relevant document retrieved,
$$\text{AP} = \frac{1}{R} \sum_{j=1}^{R} P@k_j, \qquad \text{with } P@k_j = 0 \text{ if the } j\text{-th relevant document is not retrieved.}$$
The same quantity can be written as a sum over every rank of the ranking, which is how it is usually computed. Let $\mathit{rel}(k)$ be 1 if the document at rank $k$ is relevant and 0 otherwise, and $n$ the length of the ranking. Then
$$\text{AP} = \frac{1}{R} \sum_{k=1}^{n} P@k \cdot \mathit{rel}(k).$$
The factor $\mathit{rel}(k)$ switches off the nonrelevant ranks, leaving one term per retrieved relevant document. Missing relevant documents contribute nothing to the sum but still count in $R$.
Back to the worked ranking: 5 relevant documents, retrieved at ranks 1, 3, 6, and 9, with the fifth never retrieved.
| Relevant document | Rank | Precision at that rank | Contribution $P@k_j / R$ |
|---|---|---|---|
| 1st | 1 | 1/1 = 1.000 | 0.200 |
| 2nd | 3 | 2/3 = 0.667 | 0.133 |
| 3rd | 6 | 3/6 = 0.500 | 0.100 |
| 4th | 9 | 4/9 = 0.444 | 0.089 |
| 5th | not retrieved | 0 | 0 |
Example (divide by the relevant, not the retrieved). The sum of the four precisions is divided by 5, the number of relevant documents, and not by 4, the number of them that were retrieved:
$$\text{AP} = \frac{1.000 + 0.667 + 0.500 + 0.444 + 0}{5} = 0.522.$$
Dividing by 4 would give 0.653, and would reward the system for having missed a relevant document. This is a common mistake in hand-written implementations, and it makes AP depend on how deep the ranking was cut.
AP as an area
Each relevant document advances recall by exactly $1/R$, and its contribution to AP is its precision times $1/R$. That is the area of a rectangle of width $1/R$ (the recall step) and height $P@k_j$ (the precision at the step). So AP is the total area of these rectangles. Equivalently, it is the area under the precision-recall curve when precision between recall steps is held at its value at the relevant document that ends the step.
The picture explains several properties at once.
- A missed relevant document is an empty strip on the recall axis, so it costs AP $1/R$ times whatever precision it would have had.
- A nonrelevant document never adds area, but it lowers the height of every rectangle to its right.
- AP is not the interpolated area. The rectangles are uninterpolated, so AP differs from the area under the interpolated curve. The 11-point average of the same ranking is 0.566, higher because interpolation raises each point to the best precision further along.
One query gives one AP. A collection has many queries, so the next step is to combine them.
Averaging over queries
MAP is the mean of AP over a set of queries $Q$:
$$\text{MAP} = \frac{1}{\lvert Q \rvert} \sum_{q \in Q} \text{AP}(q).$$
A second query has 3 relevant documents, retrieved at ranks 2, 5, and 8. Its AP is $(1/2 + 2/5 + 3/8)/3 = (0.500 + 0.400 + 0.375)/3 = 0.425$. The MAP over the two queries is $(0.522 + 0.425)/2 = 0.474$.
Each query counts equally, however many relevant documents it has. This is a macro-average, as defined in precision and recall, and it reflects the view that each information need matters as much as any other. A query with 200 relevant documents does not dominate one with 2.
MAP on a real collection
Two queries hide how much AP varies. On the Cranfield collection, the BM25 run from comparing ranking models has a MAP of 0.307 over 225 queries, and the individual APs span the whole range.
| Statistic of per-query AP (BM25, Cranfield) | Value |
|---|---|
| Mean (MAP) | 0.307 |
| Median | 0.250 |
| Lower and upper quartiles | 0.111 and 0.483 |
| Queries with AP = 1 | 3 |
| Queries with AP = 0 | 4 |
| Queries with AP below 0.1 | 53 |
| Share of the total AP from the best quarter of queries | 0.527 |
The best quarter of the queries contributes more than half of the sum that MAP averages. A change to the system that helps those queries a little can therefore move MAP as much as one that rescues many hard queries. The geometric mean, later in this article, addresses that problem.
The spread also matters for comparing systems. BM25 and TF-IDF differ in MAP by 0.012 on Cranfield, while the middle half of BM25's per-query APs alone spans 0.37. Differences between systems are small next to differences between queries. That is why comparisons need significance tests over the per-query values rather than a look at the two means.
Nor does the number of relevant documents explain the spread. Cranfield queries have between 1 and 39 relevant documents, and the correlation between that count and BM25's AP is −0.10. Some queries are hard for reasons the count does not capture, such as vocabulary that the relevant documents do not share. Query Performance Prediction tries to estimate each query's AP without any judgments, and scores its predictors by their correlation with BM25's per-query AP on these 225 queries.
Within one query, AP cares most about the top of the ranking, as the next section derives.
What AP rewards
AP is top-heavy: a relevant document contributes more when it is ranked earlier. Moving a relevant document up affects the score more near the top of the ranking than near the bottom.
Example (the same move, near the top and near the bottom). In the worked ranking, swapping ranks 2 and 3 changes AP more than seven times as much as swapping ranks 9 and 10. The first swap moves the second relevant document up one place, and the second moves the fourth relevant document down one place:
| Change to the ranking | AP |
|---|---|
| Original | 0.522 |
| Swap ranks 2 and 3, moving the 2nd relevant document from 3 to 2 | 0.589 |
| Swap ranks 9 and 10, moving the 4th relevant document from 9 to 10 | 0.513 |
A one-position move changes AP by 0.067 near the top of this ranking, and by only 0.009 near the bottom.
Why it happens. Here is the plan of the derivation. A one-place move of a relevant document changes only that document's own precision, so the change in AP is the change in a single fraction, and that fraction shrinks with the square of the rank.
The formal version. Suppose the $j$-th relevant document moves from rank $k$ to rank $k - 1$, swapping places with a nonrelevant document. The relevant documents before it are unaffected. So are those after it, since the number of documents and the number of relevant documents above each of them do not change. Only the moved document's own precision changes, from $j/k$ to $j/(k-1)$. So
$$\Delta\text{AP} = \frac{1}{R}\left(\frac{j}{k - 1} - \frac{j}{k}\right) = \frac{j}{R\,k\,(k - 1)}.$$
The other one-place moves follow from the same accounting, and together they cover every swap of two adjacent ranks.
A relevant document moves down past a nonrelevant one, from rank $k$ to rank $k + 1$. Again only its own precision changes, from $j/k$ to $j/(k+1)$, so
$$\Delta\text{AP} = \frac{1}{R}\left(\frac{j}{k + 1} - \frac{j}{k}\right) = -\frac{j}{R\,k\,(k + 1)}.$$
This is the previous formula read backward: moving up from $k + 1$ to $k$ gains $j/(R(k+1)k)$. In the worked ranking, the swap of ranks 9 and 10 has $j = 4$, $k = 9$: a loss of $4/(5 \times 9 \times 10) = 0.009$, from 0.522 to 0.513.
Two relevant documents, or two nonrelevant ones, trade places. AP does not change. The sequence of judgments by rank is the same before and after the swap, and AP depends only on that sequence, not on which document stands where.
These three cases are checked in the script on every ranking of eight results. Any reordering of a ranking is a sequence of adjacent swaps, so the change in AP from any reordering is a sum of such terms.
For a given $j$ the gain falls off as $1/k^2$. Across a ranking, where $j/k$ is roughly the precision at that depth, it is about $P@k/(Rk)$. It is smaller deeper down, both because $k$ is larger and because precision has usually fallen. For each relevant document of the example in turn:
| Move | $j$ | $k$ | $\Delta$AP $= j/(5k(k-1))$ | New AP |
|---|---|---|---|---|
| 2nd relevant, rank 3 to 2 | 2 | 3 | 0.067 | 0.589 |
| 3rd relevant, rank 6 to 5 | 3 | 6 | 0.020 | 0.542 |
| 4th relevant, rank 9 to 8 | 4 | 9 | 0.011 | 0.533 |
Deep documents count for little. The same reasoning explains why evaluation depth matters little once it is deep. Suppose the fifth relevant document of the example had been retrieved after all. At rank 11 it would add $(5/11)/5$, and AP would be 0.613. At rank 20 AP would be 0.572; at rank 100, 0.532; at rank 1,000, 0.523. A relevant document found very deep is worth almost nothing. TREC runs may list at most 1,000 documents per topic (Buckley and Voorhees, 2004, §2.3), and anything beyond that depth counts as not retrieved. The calculation shows that the truncation changes AP very little.
Stability. AP is the area under the uninterpolated precision-recall curve in the exact sense of the rectangles drawn above, so a single number summarizes the entire curve. (The course text says that AP "approximates" that area, §8.4, because the raw curve is a set of points and the area depends on how they are joined; with the step rule of the figure the agreement is exact.) Buckley and Voorhees (2000) measured how often a comparison of two systems on one set of topics is contradicted on another, for several measures. They found that precision at 30 documents has about twice the average error rate of average precision. That combination, one number for the whole curve and stable comparisons, is why MAP became standard.
Weaknesses
- It needs complete judgments. AP depends on $R$, the number of relevant documents, and on knowing which retrieved documents are relevant. With incomplete judgments, unjudged relevant documents are counted as nonrelevant and lower the score. In the example, suppose the document at rank 2 had never been judged but was in fact relevant. The true AP would be computed with $R = 6$ and relevant documents at ranks 1, 2, 3, 6 and 9: $(1 + 1 + 1 + 4/6 + 5/9)/6 = 0.704$, against the 0.522 reported. Measures designed for incomplete judgments are discussed in relevance judgments, pooling, and agreement.
- It is hard to explain to users. P@10 has an obvious meaning, while AP does not correspond to any simple thing a person experiences. Robertson (2008) gave it one: AP is the expected precision at the rank of a relevant document chosen at random, for a user who stops reading at that document. That is a coherent model of a user who wants every relevant document, but not of a user who wants one good answer.
- It treats relevance as binary. A highly relevant document and a marginally relevant one count the same. nDCG uses graded relevance.
Robertson's interpretation can be checked on the example. Pick one of the five relevant documents at random, each with probability 1/5, and record the precision at its rank, or 0 if it was not retrieved. The five possible outcomes are 1.000, 0.667, 0.500, 0.444, and 0. Their expected value is $2.611/5 = 0.522$, which is AP. The definition of AP is exactly this expectation; the interpretation lies in seeing the random choice as a model of where users stop.
The geometric mean
The arithmetic mean lets large gains on easy queries hide failures on hard ones. Consider two systems on four queries.
Example (a small lead in MAP, a large one in GMAP). System B is slightly worse than System A on three queries and much better on the fourth, where A nearly fails. MAP prefers B by 0.030, and the geometric mean, which is dominated by the smallest values, prefers B by 0.135:
| Query 1 | Query 2 | Query 3 | Query 4 | MAP | GMAP | |
|---|---|---|---|---|---|---|
| System A | 0.40 | 0.40 | 0.40 | 0.02 | 0.305 | 0.189 |
| System B | 0.38 | 0.38 | 0.38 | 0.20 | 0.335 | 0.324 |
MAP prefers B, by a little. The geometric mean average precision (GMAP), the geometric mean of the per-query AP values, prefers B by a lot, because a geometric mean is dominated by its smallest values. GMAP was introduced in TREC's Robust track, whose aim was to improve the worst-performing queries rather than the average (Voorhees, 2005), and Robertson (2006) later analyzed its properties.
The geometric mean is the exponential of the mean logarithm:
$$\text{GMAP} = \exp\left(\frac{1}{\lvert Q \rvert} \sum_{q \in Q} \log \text{AP}(q)\right).$$
This form shows why it rewards gains on hard queries. On the log scale, raising AP from 0.02 to 0.20 is the same improvement as raising it from 0.1 to 1: a tenfold increase. Raising it from 0.40 to 0.42 is a small one wherever it happens.
An AP of zero makes the logarithm undefined and the geometric mean zero, so in practice each AP is kept away from zero before taking the logarithm. trec_eval's gm_map replaces each AP by the larger of it and 0.00001 (National Institute of Standards and Technology, trec_eval source, m_gm_map.c); other implementations add a small constant. The choice of floor changes the value of GMAP whenever a query scores zero.
On Cranfield, with trec_eval's floor:
| Model | MAP | GMAP |
|---|---|---|
| BIM | 0.220 | 0.110 |
| TF-IDF | 0.294 | 0.166 |
| BM25 | 0.307 | 0.171 |
GMAP is about half of MAP for every model, because the many queries with AP below 0.1 weigh heavily on the log scale. BM25 leads TF-IDF by 4.2 percent in MAP and by 3.1 percent in GMAP (computed before rounding). So on this collection its advantage comes slightly more from queries that were already going well.
Other user models
Moffat and Zobel (2008) argued that a measure should start from an explicit model of how users read. Their rank-biased precision assumes that after each result a user continues to the next with a fixed probability $p$. It scores a ranking by the expected rate at which the user encounters relevant documents. Under that model the user reaches rank $i$ with probability $p^{i-1}$, so the weight of each rank falls geometrically, much faster in the tail than nDCG's logarithmic discount (the nDCG article plots these weights side by side). Unlike AP, it does not need to know the total number of relevant documents. And the parameter $p$ states directly how patient the user is assumed to be. User models behind retrieval metrics is the home of the measure: it derives the formula $(1 - p)\sum_i r_i p^{i-1}$ and its residual, computes it for the worked ranking (0.427 at $p = 0.8$), and sets Robertson's model of AP beside it.
The demo in evaluating ranked results computes AP alongside the other measures for any ranking. It shows the top-heaviness directly: moving a relevant document up one rank near the top changes AP far more than the same move near the bottom.
Worked problems
Problems 1 and 2 are exercises of the course text (Manning, Raghavan, and Schütze, 2008, Exercise 8.8 and parts e to h of Exercise 8.9; parts a to d are solved in evaluating ranked results), restated here with solutions in our own words. Problems 3 and 4 are posed on this article's two worked queries. The numbers are recomputed in tools/experiments/eval_measures/worked_examples.py.
Problem 1 (Exercise 8.8). An information need has 4 relevant documents in the collection. Two systems return these top ten results, the top of the ranking on the left:
System 1: R N R N N N N N R R
System 2: N R N N R R R N N N
(a) Find the average precision of each system, and say which is higher. (b) Say whether the result makes sense, and what it shows about a good score. (c) Find the R-precision of each system, and say whether it ranks the systems the same way.
Solution. (a) System 1 scores 0.600 and System 2 scores 0.493, so System 1 is higher. System 1 has its relevant documents at ranks 1, 3, 9 and 10, with precisions $1/1$, $2/3$, $3/9$ and $4/10$:
$$\text{AP}_1 = \frac{1 + 0.667 + 0.333 + 0.400}{4} = \frac{2.400}{4} = 0.600.$$
System 2 has them at ranks 2, 5, 6 and 7, with precisions $1/2$, $2/5$, $3/6$ and $4/7$:
$$\text{AP}_2 = \frac{0.500 + 0.400 + 0.500 + 0.571}{4} = \frac{1.971}{4} = 0.493.$$
Both systems retrieve all four relevant documents, so both sums have four nonzero terms. With one information need, MAP is the same as AP.
(b) It makes sense once the top-heaviness is taken into account. System 2 has all four relevant documents by rank 7, while System 1 needs ten ranks, so System 2 is better for a user who wants everything. But System 1 has relevant documents at ranks 1 and 3, and those two alone contribute $(1 + 0.667)/4 = 0.417$, most of System 2's whole score. Its two late documents add only 0.183. A good AP comes mainly from placing some relevant documents at the very top; where the last ones fall matters much less.
(c) With $R = 4$, R-precision is the precision of the top four. System 1 has R N R N, so $2/4 = 0.5$. System 2 has N R N N, so $1/4 = 0.25$. R-precision ranks the systems the same way as AP here. That agreement is an observation about this pair, not a rule. With $R = 4$, a ranking with relevant documents at ranks 1, 5, 6 and 7 has AP $(1 + 2/5 + 3/6 + 4/7)/4 = 0.618$ and R-precision $1/4$, while one with them at ranks 2, 3 and 4 only has AP $(1/2 + 2/3 + 3/4)/4 = 0.479$ and R-precision $3/4$. AP prefers the first and R-precision the second.
Problem 2 (Exercise 8.9, parts e to h). A ranked list of 20 documents from a collection of 10,000 has relevant documents at ranks 1, 2, 9, 11, 15 and 20, and the collection holds 8 relevant documents. (e) Taking the 20 documents as the system's complete result, find the average precision. Now suppose the system in fact ranked all 10,000 documents and these are its first 20. Find (f) the largest and (g) the smallest average precision it could have. (h) If only the top 20 are judged and the value in (e) is reported, find how large the error can be.
Solution. (e) $\text{AP} = 0.416$. The six retrieved relevant documents have precisions $1/1$, $2/2$, $3/9$, $4/11$, $5/15$ and $6/20$, and the two that were not retrieved count zero:
$$\text{AP} = \frac{1 + 1 + 0.3333 + 0.3636 + 0.3333 + 0.3000}{8} = \frac{3.3303}{8} = 0.4163.$$
(f) The largest value is 0.503. The first six terms are fixed. The two remaining relevant documents contribute most when they come as early as possible, at ranks 21 and 22, with precisions $7/21 = 0.3333$ and $8/22 = 0.3636$:
$$\text{AP}_{\max} = \frac{3.3303 + 0.3333 + 0.3636}{8} = \frac{4.0273}{8} = 0.5034.$$
(g) The smallest value is 0.4165. The two documents contribute least at the last two ranks, 9,999 and 10,000, with precisions $7/9{,}999 = 0.0007$ and $8/10{,}000 = 0.0008$:
$$\text{AP}_{\min} = \frac{3.3303 + 0.0015}{8} = 0.4165.$$
That each relevant document contributes more the earlier it stands follows from the one-place formula above: every move up past a nonrelevant document raises AP.
(h) The reported 0.4163 can be too low by as much as $0.5034 - 0.4163 = 0.087$, and by at least $0.4165 - 0.4163 = 0.0002$. It is never too high: counting the unseen relevant documents as zero gives a lower bound on the true AP. The error is one-sided and can be a fifth of the value. This is the truncation effect of the section above seen from the other side: documents found deep add almost nothing, but documents just past the cutoff add a good deal.
Problem 3 (a topic with no relevant documents). A third topic is added to the two worked queries, and it has no relevant document in the collection. Find the MAP of the three topics under the two conventions in use.
Solution. MAP is 0.474 if such topics are skipped and 0.316 if they are scored zero. For a topic with $R = 0$ the definition of AP divides by zero, so a convention is needed. Skipping the topic averages over the two topics that have relevant documents: $(0.522 + 0.425)/2 = 0.474$. Scoring it zero, as the code in implementing evaluation measures does, gives $(0.522 + 0.425 + 0)/3 = 0.316$. Neither is wrong, and the two differ by a third of the value, so a reported MAP should say which was used.
Problem 4 (the two means on the worked queries). Find the geometric mean of the average precisions of the two worked queries, compare it with their MAP, and explain the direction of the difference.
Solution. The geometric mean is 0.471, just below the MAP of 0.474. With two values the geometric mean is the square root of the product: $\sqrt{0.522 \times 0.425} = \sqrt{0.2219} = 0.471$. It is below the arithmetic mean $(0.522 + 0.425)/2 = 0.474$, as the ordering of the means requires whenever the values differ. The gap is small here because the two values are close. In the four-query example above, where one value is 0.02, the gap for System A is 0.305 against 0.189.
What we have learned
Average precision averages the precision at each relevant document over all the relevant documents, missed ones counting zero. It is an area under the precision-recall curve, and MAP is its macro-average over queries. A one-place move changes AP by $j/(Rk(k-1))$, so the measure is top-heavy. On Cranfield, per-query APs vary far more than systems do, and GMAP shifts weight toward the hard queries.
AP's binary view of relevance is the next thing to fix. Some relevant documents serve a need far better than others, as the jaguar examples of relevance show. A measure that uses graded judgments is the subject of the next article, Discounted Cumulative Gain and nDCG.
References
- Buckley, C., and Voorhees, E. M. (2000). Evaluating evaluation measure stability. In Proceedings of SIGIR 2000, 33–40. record
- Buckley, C., and Voorhees, E. M. (2004). Retrieval evaluation with incomplete information. In Proceedings of SIGIR 2004, 25–32. record · 2 pages
- Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, section 8.4. Cambridge University Press. record · 102 pages
- Moffat, A., and Zobel, J. (2008). Rank-biased precision for measurement of retrieval effectiveness. ACM Transactions on Information Systems, 27(1), article 2. record · 2 pages
- National Institute of Standards and Technology. trec_eval. https://github.com/usnistgov/trec_eval record · 4 pages
- Robertson, S. (2006). On GMAP: And other transformations. In Proceedings of CIKM 2006, 78–83. record
- Robertson, S. (2008). A new interpretation of average precision. In Proceedings of SIGIR 2008, 689–690. record · 2 pages
- Voorhees, E. M. (2005). The TREC robust retrieval track. SIGIR Forum, 39(1), 11–20. record
Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 9 revisions