prob <- 0.5; pstr0 <- 0.2; x <- (-1):20
(ii <- dzigeom(x, prob, pstr0))
max(abs(cumsum(ii) - pzigeom(x, prob, pstr0))) # Should be 0
table(rzigeom(1000, prob, pstr0))
if (FALSE) x <- 0:10
barplot(rbind(dzigeom(x, prob, pstr0), dgeom(x, prob)),
beside = TRUE, col = c("blue","orange"),
ylab = "P[Y = y]", xlab = "y", las = 1,
main = paste0("zigeometric(", prob, ", pstr0 = ", pstr0,
") (blue) vs", " geometric(", prob, ") (orange)"),
names.arg = as.character(x))
Run the code above in your browser using DataLab