draw.beta.binomial {UnivRNG} | R Documentation |
This function implements pseudo-random number generation for a Beta-binomial distribution with pmf
f(x|n,\alpha,\beta) = \frac{n!}{x!(n-x)!B(\alpha,\beta)}\int_{0}^{1}\pi^{\alpha-1+x}(1-\pi)^{n+\beta-1-x}d\pi
for x=0,1,2,...
, \alpha>0
, and \beta>0
, where n
is the sample size, \alpha
and \beta
are the shape parameters and B(\alpha,\beta)
is the complete beta function.
draw.beta.binomial(nrep,alpha,beta,n)
nrep |
Number of data points to generate. |
alpha |
First shape parameter. |
beta |
Second shape parameter. |
n |
Number of trials. |
A list of length five containing generated data, the theoretical mean, the empirical mean, the theoretical variance, and the empirical variance with names y, theo.mean, emp.mean, theo.var, and emp.var, respectively.
draw.beta.binomial(nrep=100000,alpha=0.2,beta=0.25,n=10)
draw.beta.binomial(nrep=100000,alpha=2,beta=3,n=10)
draw.beta.binomial(nrep=100000,alpha=600,beta=400,n=20)