[R] logsumexp function in R

Petr Savicky savicky at praha1.ff.cuni.cz
Thu Feb 17 07:45:30 CET 2011


On Wed, Feb 16, 2011 at 04:14:38PM -0500, Brian Tsai wrote:
> Hi,
> 
> I was wondering if anyone has implemented a numerically stable function to
> compute log(sum(exp(x))) ?

Try the following

   log(sum(exp(x - max(x)))) + max(x)

If this is not sufficient, consider using CRAN package Rmpfr with
extended arithmetic.

Petr Savicky.



More information about the R-help mailing list