Skip to contents

[Experimental]

Calculates the density function of the beta-binomial distribution.

The beta-binomial density function has the following form: p(x) = (m! / (x!*(m-x)!)) * Beta(x+a,m-x+b) / Beta(a,b)

Usage

dbetabinom(x, m, a, b, log = FALSE)

Arguments

x

(numeric):
number of successes.

m

(number):
number of trials.

a

(numeric):
first parameter of the beta distribution.

b

(numeric):
second parameter of the beta distribution.

log

(flag):
whether to return the log density value (not default).

Value

The density values of the beta-binomial distribution at x.

Examples

# dbetabinom --
dbetabinom(x = 2, m = 29, a = 0.2, b = 0.4, log = FALSE)
#> [1] 0.04286893

# Can also specify x as a vector.
dbetabinom(x = 1:28, m = 29, a = 0.2, b = 0.4, log = FALSE)
#>  [1] 0.06991718 0.04286893 0.03215170 0.02632895 0.02266016 0.02014236
#>  [7] 0.01831825 0.01694866 0.01589629 0.01507689 0.01443628 0.01393847
#> [13] 0.01355928 0.01328256 0.01309808 0.01300034 0.01298800 0.01306396
#> [19] 0.01323585 0.01351746 0.01393126 0.01451316 0.01532164 0.01645657
#> [25] 0.01810223 0.02064146 0.02503732 0.03474567