rgenpois: Sample from Generalized Poisson distribution

View source: R/rgenpois.r

rgenpoisR Documentation

Sample from Generalized Poisson distribution

Description

Sample from Generalized Poisson distribution

Usage

rgenpois(lambda = lambda, disp = disp, n = 1, scan.size = 100)

Arguments

lambda

lambda of the Generalized Poisson distribution

disp

dispersion of the Generalized Poisson distribution. Takes the value of 0 for a Poisson distribution, and becomes negative for under, and positive for over dispersed data.

n

sample size

scan.size

the upper limit of the distribution. This could be set higher but due to exponentation in the likelihood function shgould not exceed

Value

n samples from the Generalized Poisson distribution (numeric non-negative integers)

Examples

genPois.samples = sapply(seq(0.3,-1.1,-0.2), function (DISP)
{
  rgenpois(n = 10000, lambda = 22, disp = DISP)
})

# plot across dispersion
plot(range(genPois.samples), c(0,.25), type = "n", xlim = c(0,100), ylab = "Frequency")
for(i in 1 : ncol(genPois.samples)){
  gpDen = density(genPois.samples[,i], bw = 1)
  lines(gpDen)
  text(mean(genPois.samples[,i])
       , max(gpDen$y)+0.015
       , round(mean(genPois.samples[,i]),1)
       , cex = 0.5
  )
}
lines(density(rpois(10000, 11),bw = 1), col = qp.green, lwd = 3)
text(3, 0.03, round(mean(rpois(10000, 11)), 1), col = qp.green)

qPharmetra/qpToolkit documentation built on May 24, 2023, 8:52 a.m.