log_sum_exp: log_sum_exp and LSE_R

Description Usage Arguments Value Examples

View source: R/log_sum_exp.R

Description

This log_sum_exp function calculates the log sum of exponentials of two numbers. This trick is to increase accuracy and avoid underflow and overflow problems when very small or very large numbers are represented directly.

Usage

1
2
3
log_sum_exp(u, v)

LSE_R(vec)

Arguments

u

first number

v

second number

vec

vector to be summed

Value

log_sum_exp returns logged sum of exponential of u and v

LSE_R the logged sum of the exponentials of all values in vector

Examples

1
2
log_sum_exp(1, 2)
LSE_R(c(1,2,3,4))

sidiwang/hgzips documentation built on Jan. 19, 2021, 4:09 p.m.