[Math] How to calculate arithmetic mean of log values

arithmeticlogarithms

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?

Best Answer

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.