Internal function, logsum (copied from coloc package)

logsum(x)

Arguments

x

numeric vector

Value

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

Details

This function calculates the log of the sum of the exponentiated logs taking out the max, i.e. insuring that the sum is not Inf

ie, you want sum(x), but have x already stored in logs. log(sum(exp(x))) might fail, but logsum(x) should work.

Examples

x <- 1:10 log(sum(x))
#> [1] 4.007333
MFM:::logsum(log(x))
#> [1] 4.007333