# How to calculate arithmetic mean of log values

I am working with really small values of probabilities and that is why their log values are used. So for example, let probA and probB be some normal values of probabilities of two events and because they are very small, I use log values of them, $ln(probA)$ and $ln(probB)$.

I would like to compute arithmetic mean of this two values to compare them with other such pairs. Because they are very small, it is not a good idea to compute arithmetic mean like

$$\frac{e^{ln(probA)} + e^{ln(probB)}}{2}$$

Would it be mathematically correct only to compute arithemtic mean of the log values? Or is there any other better way to do it?

• Arithmetic mean of log values = $\log($Geometric mean of original values$)$. Jun 15, 2014 at 14:29
• Are you looking for the arithmetic mean of the log values or the log of the arithmetic mean of the original values? Jun 15, 2014 at 14:31
• I am looking for the log of the arithmetic mean of the original values, but I have only log values of the original values Jun 15, 2014 at 14:35
• and I don't want to work with original values Jun 15, 2014 at 14:50
• There's nothing wrong with just working with logs all the way. Compute the means, compare etc. Jun 15, 2014 at 15:01

What you really want is the $\ln$ of the arithmetic mean. That is: $$\ln\left(\frac12(e^{\ln(\Pr(A))} + e^{\ln(\Pr(B))}\right ) .$$ Assume without loss of generality that $\Pr(A) \ge \Pr(B)$. Factor it: $$-\ln(2) + \ln(\Pr(A)) + \ln\left(1 + e^{\ln(\Pr(B)) - \ln(\Pr(A))}\right) .$$ Doing the computation like this will probably result in small numerical errors.
• I don't think you can avoid the calculation $e^{\ln(\Pr(B))-\ln(\Pr(A))}$. There is only one formula for the arithmetic mean, and all you can do is to rearrange it. However, if $\Pr(A) \gg \Pr(B)$, then $\ln(\Pr(B))-\ln(\Pr(A))$ will be a large negative number, and so $e^{\ln(\Pr(B))-\ln(\Pr(A))}$ will be very close to zero. This means (a) that you can use the Taylor series expansion of $\ln(1+x)$ with only a few terms, and (b) if $e^{\ln(\Pr(B))-\ln(\Pr(A))}$ is so small that is causes an underflow, then you can replace it by zero. Jun 15, 2014 at 19:31
• Would I be correct in presuming that the first equation generalises to $$\ln\left(\frac1N(e^{\ln(\Pr(A))} + e^{\ln(\Pr(B))} + ... + e^{\ln(\Pr(N))}\right ) ?$$ Nov 16, 2018 at 9:51