Learn R Programming

mgcv (version 1.9-4)

dppois: Stable evaluation of difference between Poisson c.d.f.s

Description

Evaluates the difference between two Poisson cumulative distribution functions avoiding cancellation error.

Usage

dppois(y0,y1,mu,log.p=TRUE)

Arguments

y0

vector of lower values at which to evaluate Poisson distribution function.

y1

vector of upper values at which to evaluate Poisson distribution function.

mu

vector giving Poisson means

log.p

set to FALSE to compute on probability scale.

Author

Simon N. Wood simon.wood@r-project.org

Details

Equivalent to log(ppois(y1,mu)-ppois(y0,mu)), but stable when y0 and y1 are highly improbable and in the same tail of the distribution (avoids cancellation to log(0)).

Examples

Run this code
require(mgcv)
n <- 10
mu <- rep(2,n)
y0 <- c(0:5,10,23,0,2)
y1 <- c(1:6,11,1000,100,40)
dppois(y0,y1,mu)
log(ppois(y1,mu)-ppois(y0,mu))

Run the code above in your browser using DataLab