# On average of percents

I have read some pages about how to calculate the average of percents. However, still I don't understand something...

Assume data points are organized in the following manner: We have two categories and each category contains some malware files. We run a virus detection program to see how many files are detected as malware. So, for SET1, there are 30 files and we have detected 25 viruses. The coverage is then 83.3%. The same is true for SET2.

          items         detected          percent
set1      30              25              83.3%
set2      80              40              50%


Now, we want to know what is the average coverage for this program. We have two methods:

1- We can say, there are totally 110 files (30+80) and totally 65 files (25+40) are detected. So, the average coverage is 65*100/110 which is 66.6%

2- We can calculate (83.3+50)/2 which is 59%.

Which one is more meaningful?

• Related question and answer: stats.stackexchange.com/a/144067/168251 – afagarap Dec 28 '18 at 9:11
• That is talking about measurements in time. However, mine is not related to time. So, I think that is not applicable here. – mahmood Dec 28 '18 at 9:16
• You could average it as how you would regularly do it, unless the percentages are weighted. – afagarap Dec 28 '18 at 9:18
• Both are equally "correct," depending on what this average is intended to estimate. Please edit your post to clarify what the purpose of your analysis might be. – whuber Dec 28 '18 at 16:03
• @whuber: I have edited the post with more details. – mahmood Dec 31 '18 at 12:34

## 1 Answer

59% is correct.

You can caluclate it like this: (30 * 83.3% + 80 * 50%)/110 = 59%

The problem with averaging percentages directly is that you don't take into account the numbers that these percentages refer to. If you had the equal number of elements in set1 and set2, you'd get the same result, but since one set has more elements than the other, the percentage has to be weighted.

• But (83.3+50)/2 is not weighted as far as I could understand. Both numbers are normalized to 100. – mahmood Dec 28 '18 at 9:57
• 83% of 30 is not the same as 83% of 1000000. That's the whole point. – Kresimir Dec 28 '18 at 16:52