logsum: logsum

Description Usage Arguments Details Value Author(s) Examples

View source: R/marginalpp.R View source: R/marginalpp.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/MTFM documentation built on Aug. 15, 2019, 6:14 p.m.