How to calculate the below equation
$$\ln \frac{e^{x_1}+e^{x_2}+....+e^{x_n}}{n}$$
where $x_i, i=1...n$ and $n$ are some known values. In addition, $n=200$ and $x_i \in [1000, 2000]$. Or could we use some numerical ways to get the solution?
Any help would be appreciated.
With $x_1\geq x_2\geq \ldots \geq x_n$, I expect that resorting to well-known log-sum-exp trick might provide an accurate answer: \begin{align} \ln (e^{x_1}+e^{x_2}+\ldots+e^{x_n})=x_1+\ln (1+e^{x_2-x_1}+\ldots+e^{x_n-x_1}). \end{align} The remaining thing is truncating the summation so as to strike a balance on the accuracy and the computational feasibility. I expect approximating it with \begin{align} x_1+\ln (1+e^{x_2-x_1}+\ldots+e^{x_m-x_1}) \end{align} where $|x_m-x_1|\approx \text{(few tens)}$ will be quite good. In this case, the approximation error is just \begin{align} |\ln (1+e^{x_2-x_1}+\ldots+e^{x_n-x_1})-\ln (1+e^{x_2-x_1}+\ldots+e^{x_m-x_1})|&\leq e^{x_{m+1}-x_1}+\ldots+e^{x_n-x_1}\\ &\leq ne^{x_m-x_1} \end{align} For instance, if you let $|x_m-x_1|\approx -20$, the bound becomes $200 e^{-20}\approx 4.12\times 10^{-7}$.