twLogSumExp: twLogSumExp

Description Usage Arguments Details Author(s)

View source: R/misc.R

Description

calculates the log(sum(exp(x))) in numerically safer way

Usage

1
twLogSumExp(x, shiftUpperBound = FALSE, shiftLowerBound = FALSE)

Arguments

x

vector to be summed

shiftUpperBound

use this if x has a clear upper bound

shiftLowerBound

use this if x has a clear lower bound

Details

Before taking the exponent, all x are shifted towards zero. By default the median of x is subtracted. If shiftUpperBound then max(x) is subtracted. This is useful if the distribution of x has a strong left tail but a defined upper bound. If shiftLowerBound then min(x) is subtracted. This is useful if the distribution of x has a strong right tail but a defined lower bound.

Author(s)

Thomas Wutzler


twMisc documentation built on May 2, 2019, 6:11 p.m.