# NOT RUN {
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)
# }
Run the code above in your browser using DataLab