0

I want a workaround for the geometric mean when the data contains negative numbers. I found this on Wikipedia, but it doesn't work if m is odd and there is an even number of data points. What should the correct formula be?

enter image description here

where m is the number of negative numbers.

https://en.wikipedia.org/wiki/Geometric_mean

Greg
  • 283
  • 1
  • 7
  • If the number of negative numbers is odd the product of all of them is negative. What interpretation of the geometric mean do you want in this case? – quarague Apr 03 '22 at 16:30
  • Let $n=4, a_1=-e, a_2=a_3=a_4=e$. Thus $m=1$. Then $((-e)\cdot e\cdot e\cdot e)^{0.25}=(-1)^{1\cdot 0.25}\cdot e$. The equation holds. – callculus42 Apr 03 '22 at 16:48
  • (−1)^(1⋅0.25) returns #NUM! in Excel – Greg Apr 03 '22 at 17:51
  • 3
    The geometric mean is a useful concept when dealing with positive data. But for negative data, it stops being useful. Even in the cases where it is defined (in the real numbers), it is no longer guaranteed to give a useful response. Consider the "geometric mean" of $-1$ and $-4$. Your knee-jerk formula of $\sqrt{(-1)(-4)} = 2$ gives you a result that is obviously well removed from the inputs. Using the negative root here might make sense, but then what do you do about $-100, -1, 4, 25$? So in general, if you have a mix of positive and negative values, forget the geometric mean. – Paul Sinclair Apr 04 '22 at 15:40
  • 1
    +1 for @PaulSinclair 's comment. The geometric mean is not your friend here. If you [edit] the question to tell us what your data mean and why you think it's what you need in your application we may be able to help. – Ethan Bolker Apr 04 '22 at 16:13
  • 1
    What do you want it for? We can propose a lot of variants, I suppose, but what will suit your purpose depends on your purpose. – Thomas Andrews Apr 04 '22 at 19:02
  • What Excel does is not math, however. – Thomas Andrews Apr 04 '22 at 19:05
  • @Greg A reply would be nice. – callculus42 Apr 05 '22 at 14:13
  • I've always known that the geometric mean could only be used with positive numbers, but recently saw that there were "modified formulas" for negative numbers. I got curious, found a few interesting things (such as a series of investment returns - which doesn't give the same result if all returns are positive), then found this on Wikipedia but still end up with the imaginary number. I was really just curious. – Greg Apr 05 '22 at 22:02
  • @Greg Since all is clear now, it would be a good idea to accept the answer. Thanks in advance. – callculus42 Jul 21 '23 at 22:40

1 Answers1

0

The formula is for geometric means where you at least take the n-th root of a negative number, namely $(-a)^{\frac1{n}}$, $a\geq 0$. This results in a complex number. First of all we have the identity $\left(e^{i\cdot \pi}\right)^n=(-1)^n $. That means that $(-1)^{0.25}=e^{i\cdot \pi\cdot 0.25}$

Then we apply Euler's formula: $e^{ix}=\cos(x) + i\cdot \sin (x)$. Thus $e^{i\cdot \pi\cdot 0.25}=\cos(\pi\cdot 0.25) + i\cdot \sin (\pi\cdot 0.25)=\frac1{\sqrt2}+\frac1{\sqrt2}\cdot i$. Finally we obtain

$$((-e)\cdot e\cdot e\cdot e)^{0.25}=\frac{e}{\sqrt2}+\frac{e}{\sqrt2}\cdot i=1.92212...+1.92212...i$$

It seems that Excel cannot handle complex numbers. That's why it returns #NUM!

One of my main interest is economics. One application is to calculate the average growth rate $\overline r$. For this purpose we use the growth fractors $1+r_i$. Then the average growth rate in n periods is $\overline r=\sqrt[n]{\prod\limits_{i=1}^n (1+r_i)}-1$. Even if $r_i$ is negative the factors $1+r_i$ remains non-negative since $r_i\geq -1$. A given amount cannot decrease more than 100%. But maybe there are other fields where it makes sense to take a root of a negative number.

callculus42
  • 30,550
  • 1
    Use \sqrt[n]{...} for $\sqrt[n]{...}$ – Thomas Andrews Apr 04 '22 at 19:09
  • @ThomasAndrews I wanted to type $\sqrt[n]{\prod}$. Thanks for the hint. I thought it was obvious. – callculus42 Apr 04 '22 at 19:10
  • I've seen this workaround for, say, rates of return. I am bothered by the fact that, if the numbers are all positive, the result is not the same as \sqrt[n]{∏ai} (nth root of the product of the entries). – Greg Apr 05 '22 at 21:46
  • @Greg I'm not sure what you mean, If $a_i$ the rates of return of period $i$ then the average rate of return over all $n$ periods is $\overline a=\sqrt[n]{\prod\limits_{i=1}^n (1+a_i)}-1$. If $a_i$ is constant over all $n$ periods then the average rate of return is $\overline a=a_i$. See here an example for $n=6$ and $a_i=0.1$ – callculus42 Apr 06 '22 at 01:20
  • I don't understand why you would hold a_i constant. Suppose a_i = 2%, 3%, 4%, and 5%, n=4. The standard geometric mean formula give 3.31%. This one give 3.49%. – Greg Apr 06 '22 at 03:20
  • How do you format these in the comments? – Greg Apr 06 '22 at 03:21
  • @Greg If you have growth rates you take the n-th roots of the growth factors. That means that $x_i$ (wiki) is equal to $1+r_i$. For instance, if you have two periods: One with growth rate $0.5$ and the other with growth rate $0.2$. Then after the two periods you have $1.2\cdot 1.5=1.8$ The average growth rate then is $\sqrt(1.2\cdot 1.5)-1=03416407865...$. And the overall growth is amount after two periods $1.3416407865^2=1.8$. To summarize: You calculate the geometric mean of the growth factors to obtain the average growth factor. Then you subtract 1 to obtain the average growth rate. – callculus42 Apr 06 '22 at 14:35
  • @Greg You do not calculate the geometric mean of the growth rates as $\sqrt{0.2⋅0.5}=\sqrt{0.2\cdot 0.5}=0.3162277... \ \ \color{red}X$ To format the comments/answers I use $\LaTeX$. See here for some tips. In general you have to put $$$ around the $\LaTeX$-formulas. – callculus42 Apr 06 '22 at 14:54
  • The case of decreasing is probably more obvious: If something decrease by $0.2$ and $0.4$ then the decreasing factors are $(1-0.2)$ and $(1-0.4)$. As I said the factors do not get negative. The overall decreasing factor is $(1-0.2)\cdot (1-0.4)=0.8\cdot 0.6=0.48$. If you had an amount of 100 at the beginning, then after two periods the amount reduces to $100\cdot 0.48=48$ The overall decreasing rate is $0.8\cdot 0.6-1=-0.52$ So you loose $52$ from $100$ – callculus42 Apr 06 '22 at 15:45