Gentbinom {VGAM} | R Documentation |
Density, distribution function, and random generation for the generally-truncated binomial distribution.
dgentbinom(x, size, prob, truncate = 0, log = FALSE) pgentbinom(q, size, prob, truncate = 0) rgentbinom(n, size, prob, truncate = 0, maxits = 10000)
x, q |
vector of quantiles. |
n |
number of observations.
Fed into |
size, prob, log |
See |
truncate |
vector of integers from the set |
maxits |
Maximum number of iterations; used to avoid an infinite loop.
If exceeded, random variates of |
The generally-truncated binomial distribution is a binomial distribution with the probability of certain (truncated) values being zero. The other probabilities are scaled to add to unity.
dgentbinom
gives the density,
pgentbinom
gives the distribution function,
rgentbinom
generates random deviates.
The function can run slowly for certain combinations
of size
, prob
and truncate
, e.g.,
rgentbinom(100, size = 10, prob = 0.1, trunc = 0:4)
.
Failure to obtain random variates will result in some
NA
values instead.
T. W. Yee.
gentbinomial
,
Genabinom
,
Genibinom
,
dposbinom
,
rbinom
,
gentpoisson
.
size <- 10; prob <- 0.5 y <- rgentbinom(n = 1000, size, prob, truncate = 3:5) table(y) tvec <- c(4, 5, 7) # Truncate these values (ii <- dgentbinom(0:7, size, prob, truncate = tvec)) table(rgentbinom(100, size, prob, truncate = tvec)) ## Not run: x <- 0:size barplot(rbind(dgentbinom(x, size, prob, truncate = tvec), dbinom(x, size, prob)), beside = TRUE, col = c("blue", "orange"), main = paste("Gen-trunc Binomial(", size, ", ", prob, ", truncate = c(", paste(tvec, collapse = ", "), ")) vs", " Binomial(", size, ", ", prob, ")", sep = ""), sub = "Generally-truncated binomial is blue; Binomial is orange", names.arg = as.character(x), las = 1, lwd = 2) ## End(Not run)