The above diagram shows a standard example of precision and recall in a document retrieval setting.
To calculate the average precision for rank 1 you would just do:
(1.0 + 0.67 + 0.75 + 0.8 + 0.83 + 0.6) / 6 = 0.78
The example above is great for small document collections but say you have a search engine with 100,000s of documents and a query could have 100 of relevant documents. How would the above be adapted if you kept the length of K at 10?
An example:
It has been decided that the query for Ranking #1 has 20 relevant documents does the above become:
(1.0 + 0.67 + 0.75 + 0.8 + 0.83 + 0.6) / 20 = 0.23
or do you still divide by 6 because that is the number of relevant documents within the rank of length K?