Description Usage Arguments Details Value Author(s) References Examples
Obtain log(sum(x)) from log(x), without passing to exponentials. It is based on the fact that log(a + b) = log(a) + log (1 + exp(log(b) - log(a))).
1 | sumlog(x,lower=-745,upper=709)
|
x |
Vector of log-values |
lower |
Value such that exp(lower-epsilon)=0 |
upper |
Value such that exp(upper+epsilon)=Inf |
This function computes the logarithm of the sum of exp(x), without passing through exponentials. It shall be used to avoid under/over flow. It has proven useful in computing the likelihood of finite mixture models, normalization constants, importance sampling, etc. It is described in the appendix of Farcomeni (2012).
A scalar equal to log(sum(exp(x)))
.
Alessio Farcomeni alessio.farcomeni@uniroma1.it, Andy Leung andy.leung@stat.ubc.ca
Farcomeni, A. (2012) Quantile Regression for longitudinal data based on latent Markov subject-specific parameters. Statistics and Computing, 22, 141-152
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Loading required package: Rcpp
Loading required package: mvtnorm
Loading required package: MASS
[1] -Inf
[1] -749.8731
[1] -744.4401
[1] -744.9991
[1] 1.609438
[1] 1.609438
[1] 1.609438
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.