logsum: logsum

Description Usage Arguments Details Value Author(s) Examples

View source: R/flashfm.R

Description

Internal function, logsum (copied from coloc package)

Usage

1
logsum(x)

Arguments

x

numeric vector

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.

Value

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

Author(s)

Claudia Giambartolomei

Examples

1
2
3
x <- 1:10
log(sum(x))
MFM:::logsum(log(x))

jennasimit/flashfm documentation built on Aug. 9, 2021, 7:36 a.m.