Density, and random generation
for the zero-inflated geometric distribution with parameter pstr0
.
dzigeom(x, prob, pstr0 = 0, log = FALSE)
pzigeom(q, prob, pstr0 = 0)
qzigeom(p, prob, pstr0 = 0)
rzigeom(n, prob, pstr0 = 0)
vector of quantiles.
vector of probabilities.
see dgeom
.
Same as in runif
.
Probability of structural zero (ignoring the geometric distribution),
called
Logical. Return the logarithm of the answer?
dzigeom
gives the density,
pzigeom
gives the distribution function,
qzigeom
gives the quantile function, and
rzigeom
generates random deviates.
The probability function of
# NOT RUN {
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))
# }
# NOT RUN {
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 = paste("zigeometric(", prob, ", pstr0 = ", pstr0,
") (blue) vs",
" geometric(", prob, ") (orange)", sep = ""),
names.arg = as.character(x))
# }
Run the code above in your browser using DataLab