Description Usage Arguments Details See Also Examples
Probability mass function and random generation for the beta-binomial distribution.
1 2 3 4 5 |
x, q |
vector of quantiles. |
size |
number of trials (zero or more). |
alpha, beta |
non-negative parameters of the beta distribution. |
log, log.p |
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x]. |
n |
number of observations. If |
If p ~ Beta(α, β) and X ~ Binomial(n, p), then X ~ BetaBinomial(n, α, β).
Probability mass function
f(x) = choose(n, x) * B(x+α, n-x+β) / B(α, β)
Cumulative distribution function is calculated using recursive algorithm that employs the fact that Γ(x) = (x - 1)!, and B(x, y) = (Γ(x)Γ(y))/Γ(x+y) , and that choose(n,k) = prod((n+1-(1:k))/(1:k)) . This enables re-writing probability mass function as
f(x) = prod((n+1-(1:x))/(1:x)) * (((α+x-1)!*(β+n-x-1)!)/((α+β+n+1)!)) / B(α, β)
what makes recursive updating from x to x+1 easy using the properties of factorials
f(x+1) = prod((n+1-(1:x))/(1:x)) * ((n+1-x+1)/(x+1)) * (((α+x-1)!*(α+x)*(β+n-x-1)!/(β+n-x))/((α+β+n+1)!*(α+β+n))) / B(α, β)
and let's us efficiently calculate cumulative distribution function as a sum of probability mass functions
F(x) = f(0)+...+f(x)
1 2 3 4 5 6 7 8 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.