Gentbinom {VGAM} | R Documentation

## Generally-Truncated-Binomial Distribution

### Description

Density, distribution function, and random generation for the generally-truncated binomial distribution.

### Usage

    dgentbinom(x, size, prob, truncate = 0, log = FALSE)
    pgentbinom(q, size, prob, truncate = 0)
    rgentbinom(n, size, prob, truncate = 0, maxits = 10000)

### Arguments

`x, q` | vector of quantiles.

`n` | number of observations. Fed into `rbinom`.
`size, prob, log` | See `rbinom`.
`truncate` | vector of integers from the set `0:size`; the truncated values. Must have unique values only. A `NULL` is acceptable and means an empty set.
`maxits` | Maximum number of iterations; used to avoid an infinite loop. If exceeded, random variates of `NA`s are returned.

### Details

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.

### Value

`dgentbinom` gives the density, `pgentbinom` gives the distribution function, `rgentbinom` generates random deviates.

### Warning

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.

### Author(s)

T. W. Yee.

### See Also

`gentbinomial`, `Genabinom`, `Genibinom`, `dposbinom`, `rbinom`, `gentpoisson`.

### Examples

    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)

[Package VGAM version 1.1-1 Index]