# Geometric mean of a dataset containing $0$s

We are taught that geometric mean (GM) should only be applied to a dataset of positive numbers, and some insist that it should be strictly positive numbers.

However, I have seen people discussing the calculation of the GM of a dataset which contains $0$s. And there seem to be at least two ways to deal with such situation:

1. If there exists a $0$ in the dataset, then the GM is also $0$

2. Substitute the $0$s with some other number (e.g. $1$), then work out the GM as usual

Can someone please share their opinion on when we should apply method 1) instead of method 2) and why (i.e. the justifications), and vice versa? In addition, intuitively, why we want to do 1) as it essentially throws away all the other non-zero values in the dataset? Thanks.

• For what purpose are you computing the geometric mean of your data at all? This may well affect how you should go about it. Dec 14, 2011 at 15:13
• I can't imagine a situation where you'd ever want to use (2). You might want to discount 0s entirely, but that is not the same thing as treating them as 1. For example, if your dataset is $(0,4,16)$, if you treat zero as $1$, you'd be taking the geometric mean of $(1,4,16)$ which is $4$. But if you "ignore" the zeros, you'd take the geometric mean of $(4,16)$, which is $8$. Dec 14, 2011 at 15:20
• @ChrisEagle, I want to see the population consensus of their choices. For example, if each value in the dataset represents a choice out of $1$-$10$, then I want to get an estimate of the population consensus. Dec 14, 2011 at 16:08
• @ballib Why would you use the geometric mean to compute that? I can think of good arguments for using the mean, the median or the mode, but I can't think of any good reason for using the geometric mean. What does a zero value represent in this dataset? Is it a code for a question that wasn't answered? Dec 14, 2011 at 16:13
• @ChrisTaylor, sorry, a typo in my comment above, should be "a choice out of $0$-$10$". In addition, another context I am interested in using geometric mean is that if I have 10 distributions over the same random variable, then I wonder if I can use GM to work out the 'average' probability of each outcome, and potentially some distribution(s) may have $0$ for certain outcome. Dec 14, 2011 at 16:30

Well, the geometric mean of a set of points $\{p_1,\dots,p_n\}$ is given by $$\left(\prod_{i=1}^np_i\right)^{1/n}$$ so if any of the $p_i$ are zero, the whole product and hence whole expression will be zero.

The substitution method is used when you want to take the logarithm of the geometric mean (which will convert products into sums); zeros are excluded because the logarithm of zero is undefined.

Systematically, option 1 is the right one because a geometric mean is an $n$th root of the product of the data points, and if one of the points is zero, then that collapses the entire product into 0.
Intuitively, you can also look at this by considering that the geometric mean is the antilogarithm of the artithmetic mean of the logarithms of the data points, and the logarithm of 0 is (remember, we're speaking intuitively here) $-\infty$, so it drags the mean of the logarithms clean down to $-\infty$ too.
You can also argue by continuity: If you have a set of data points, and begin to shrink one of them towards zero, keeping the others unchanged, the geometric mean of all of them will also eventually drop towards zero. If you single out a true $0$ for different processing from a value that is merely very small, the output will be discontinuous as a function of the inputs -- that is, at the time your shrinking value hits $0$ exactly, the mean would jump upwards, which is counterintuitive too.