Skip to contents

Calculates density of the binomial distribution where support for 0 has been removed, and which we refer to as the (zero-) truncated binomial distribution (e.g., Rider, 1955; Stephan, 1945).

Usage

dtruncbinom(x, size, prob)

Arguments

x

vector of values

size

(scalar) number of trials (n); must be 1 or more

prob

(scalar) probability of success on each trial (p); must be nonzero

Value

Vector of densities associated with the provided values (x) for given parameters

Details

Let \(X\) denote a random variable with probability mass function (pmf) of

\(\mathrm{p}(k;n,p) = \mathrm{Pr}(X = k; n, p) = \frac{\binom{n}{k} p^k (1-p)^{n-k}}{1 - (1-p)^n} \propto \binom{n}{k} p^k (1-p)^{n-k}\),

for \(k = 1, 2, ..., n\), and with zero mass, otherwise. We say that \(X\) is truncated binomial with parameters \((n,p)\), written as \(X \sim TBinom(n,p)\), and where \(n\) refers to the number of trials and \(p\) refers to the probability of success of each trial for the corresponding binomial distribution.

References

Rider, P. R. (1955). Truncated binomial and negative binomial distributions. Journal of the American Statistical Association, 50(271), 877-883.

Stephan, F. F. (1945). The expected value and variance of the reciprocal and other negative powers of a positive Bernoullian variate. The Annals of Mathematical Statistics, 16(1), 50-61.

See also

calc_moments_truncbinom() for computing TBinom moments

Examples

dtruncbinom(1:20, 20, .2)
#>  [1] 5.831844e-02 1.385063e-01 2.077594e-01 2.207444e-01 1.765955e-01
#>  [6] 1.103722e-01 5.518610e-02 2.241935e-02 7.473118e-03 2.055107e-03
#> [11] 4.670699e-04 8.757560e-05 1.347317e-05 1.684146e-06 1.684146e-07
#> [16] 1.315739e-08 7.739642e-10 3.224851e-11 8.486450e-13 1.060806e-14

#same as above
dbinom(1:20, size = 20, prob = .2) / sum(dbinom(1:20, size = 20, prob = .2))
#>  [1] 5.831844e-02 1.385063e-01 2.077594e-01 2.207444e-01 1.765955e-01
#>  [6] 1.103722e-01 5.518610e-02 2.241935e-02 7.473118e-03 2.055107e-03
#> [11] 4.670699e-04 8.757560e-05 1.347317e-05 1.684146e-06 1.684146e-07
#> [16] 1.315739e-08 7.739642e-10 3.224851e-11 8.486450e-13 1.060806e-14