logsumexp: Computing Log-Sum-Exp with a common trick

Description Usage Arguments Value Author(s) References Examples

Description

Computes log-sum-exp of a series of (typically large in absolute value) numbers with a more accurate computational trick typically useful for small values.

Usage

1
LogSumExp(x, byrow = TRUE, bycol = !byrow)

Arguments

x

A vector or a matrix of numerics (typicall very small).

byrow

Logical. Computes by rows if a matrix "x" is provided.

bycol

Logical. Computes by cols if a matrix "x" is provided.

Value

Log-Sum-Exp of the numbers in the vector "x", that is log(sum(exp(x))), or row-/column-wise Log-Sum-Exp of the numbers in a matrix "x".

Author(s)

Yunlong Jiao

References

Computing Log-Sum-Exp: https://hips.seas.harvard.edu/blog/2013/01/09/computing-log-sum-exp/

Examples

1
2
x <- c(-1000, -999, -1000)
LogSumExp(x)

YunlongJiao/kernrank documentation built on May 10, 2019, 1:13 a.m.