log_pvalue: Logarithm of a tail sum of the 'L'-fold convolution of...

Description Usage Arguments Value References See Also Examples

View source: R/sisfft.R

Description

log_pvalue returns the logarithm of an approximation to the tail sum from index s0 of the convolution of exp(log_pmf) with itself L times. The approximation has relative error bounded by gamma. That is, if P = sum(q[s0:length(q)]) with q = p * p * ... * p (where the * denote L convolutions), then the approximation Q satisfies abs(Q - P) <= gamma * P.

Usage

1
log_pvalue(log_pmf, s0, L, gamma)

Arguments

log_pmf

a numeric vector, the logarithm of a pmf.

s0

a positive integer, the index for which the tail sum should be computed.

L

a positive integer giving the the number of times to convolve log_pmf with itself.

gamma

a positive number less than 0.5, to control the relative error.

Value

A number that is the logarithm of the approximation to the tail sum.

References

Huon Wilson, Uri Keich, Accurate small tail probabilities of sums of iid lattice-valued random variables via FFT, Submitted.

See Also

log_convolve log_convolve_power

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pmf <- c(0.5, 0.5)
log_pval <- log_pvalue(log(pmf), 52, 101, 1e-3)
abs(exp(log_pval) - 0.5) <= 1e-3 * 0.5

pmf <- exp(30:1) / sum(exp(30:1))
# 2901 is the last entry in the convolution
log_pval <- log_pvalue(log(pmf), 2901, 100, 1e-3)
# (much) smaller than smallest double
log_pval < log(.Machine$double.xmin)

exact <- log(pmf[30]) * 100
# relative error, without underflow
abs(expm1(log_pval - exact)) <= 1e-3

huonw/sisfft documentation built on May 17, 2019, 9:13 p.m.