I have a data set of two columns. The first divided by the second will give the percentage, and I am trying to find the average of these percentages.

However, the second column will sometimes be 0, in which case I set the rate to be 0 to avoid a division by 0 error. Due to this 0 error, the following methods will give two different answers and I wondered which one is more correct.

Method 1

Total each of the two original columns and divide the first total by the second.

Method 2

Find the mean average of the percentages column, including the ones that I have set to zero.


0 | 3

2 | 0

4 | 1

7 | 4

0 | 5

So, if we use method one: (0+2+4+7+0) / (3+0+1+4+5) = 1

And using method two: (0/3 + 0 + 4/1 + 7/4 + 0/5) does not equal 1

Thanks in advance :)


First note that the division by zero is not permitted, so when you have a null denominator and you set that rate to be $0$ you are doing something that is mathematically wrong. Maybe that this has some sense in your situation (I don't know), but the change rate is simply not defined in this situation.

Second: Your method 1) giwe something different than the mean of the change rates, it gives the total change rate of all the set of inputs that, also if all single change rates are defined, is different from the mean of the change rates.

In conclusion: we cannot evaluate the mean of a set of change rates if some of this rates is not defined, we can evalute the rate of total change, but this is a different thing. If this value is significative in your problem, depends from the problem.


The ratio of the sum of two sets of data, which is the ratio of their aritmetic averages, is not the mean of the single averages, but their weighted mean as shown here: $$ \frac{{\sum {a_k } }} {{\sum {b_k } }} = \frac{{1/n\;\sum {a_k } }} {{1/n\;\sum {b_k } }} = \frac{{\bar a}} {{\bar b}} = \sum {\frac{{a_k }} {{b_k }}\left( {\frac{{b_k }} {{\sum {b_k } }}} \right)} $$ That stated, if some of values of the $b$ set are null, and you want to compute the sum ratio through the wighted mean then, to avoid the $/0$ error, you can assign to those element a very low value (within the significant digits of your program) $$ \frac{{\bar a}} {{\bar b}} = \mathop {\lim }\limits_{b_{\,j} \; \to \,0\;} \sum {\frac{{a_k }} {{b_k }}\left( {\frac{{b_k }} {{\sum {b_k } }}} \right)} $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.