Genabinom {VGAM} | R Documentation |
Density, distribution function, and random generation for the generally-altered binomial distribution.
dgenabinom(x, size, prob, alter = 0, pobs.a = 0, byrow.arg = FALSE, log = FALSE) pgenabinom(q, size, prob, alter = 0, pobs.a = 0, byrow.arg = FALSE) rgenabinom(n, size, prob, alter = 0, pobs.a = 0, byrow.arg = FALSE, maxits = 10000)
x, q, n, log |
Same type of argument as in |
size, prob |
vector of positive means (of an ordinary binomial distribution). Short vectors are recycled. |
alter |
vector of nonnegative integers; the altered values.
Must have unique values only.
A |
pobs.a, byrow.arg |
Same as |
maxits |
Fed into |
The generally-altered binomial distribution is a binomial
distribution with
the probability of certain (altered) values having some
prespecified probabilities.
It can be considered a mixture of a multinomial distribution
and a generally-truncated binomial distribution.
Since alter = 0
and pobs.a = 0
then
the default is a 0-truncated (positive) binomial distribution.
dgenabinom
gives the density,
pgenabinom
gives the distribution function,
rgenabinom
generates random deviates.
See rgentbinom
.
The function can run slowly for certain combinations
of pobs.a
and alter
, e.g.,
rgenabinom(1e5, 10, 0.1, alter=0:9, pobs.a = seq(10)/56, byrow=TRUE)
.
Failure to obtain random variates will result in some
NA
values instead.
T. W. Yee.
Genibinom
,
Gentbinom
,
dposbinom
,
rbinom
.
avec <- 2:4 # Alter these values pobs.a <- (1:3)/10; size <- 10; prob <- 0.5; y <- rgenabinom(1000, size, prob, alter = avec, pobs.a = pobs.a, byrow = TRUE) table(y) (ii <- dgenabinom(0:7, size, prob, alter = avec, pobs.a = pobs.a, byrow = TRUE)) table(rgenabinom(100, size, prob, alter = avec, pobs.a = pobs.a, byrow = TRUE)) ## Not run: x <- 0:size barplot(rbind(dgenabinom(x, size, prob, alter = avec, pobs.a = pobs.a, byrow = TRUE), dbinom(x, size, prob)), beside = TRUE, col = c("blue", "orange"), main = paste("Gen-alt Binom(size = ", size, ", ", "prob = ", prob, ", ", "alter = c(", paste(avec, collapse = ","), "), pobs.a = c(", paste(pobs.a, collapse = ","), "), byrow = TRUE) vs", " Binom(", size, ", ", prob, ")", sep = ""), sub = "Generally-altered binomial is blue; binomial is orange", names.arg = as.character(x), las = 1, lwd = 2) ## End(Not run)