Learn R Programming

pomp (version 2.8)

logmeanexp: The log-mean-exp trick

Description

logmeanexp computes $$\log\frac{1}{N}\sum_{n=1}^N\!e^x_i,$$ avoiding over- and under-flow in doing so. It can optionally return an estimate of the standard error in this quantity.

Usage

logmeanexp(x, se = FALSE)

Arguments

x

numeric

se

logical; give approximate standard error?

Value

log(mean(exp(x))) computed so as to avoid over- or underflow. If se = FALSE, the approximate standard error is returned as well.

Details

When se = TRUE, logmeanexp uses a jackknife estimate of the variance in \(log(x)\).

Examples

Run this code
# NOT RUN {
## an estimate of the log likelihood:
po <- ricker()
ll <- replicate(n=5,logLik(pfilter(po,Np=1000)))
logmeanexp(ll)
## with standard error:
logmeanexp(ll,se=TRUE)
# }

Run the code above in your browser using DataLab