Allele-frequency estimator under Hardy-Weinberg equilibrium (source code)

= Allele-frequency estimator under Hardy-Weinberg equilibrium

From genotype counts in $n$ independent diploid individuals, the unbiased and maximum-likelihood estimator of the frequency of allele $B$ is
$$
\widehat\theta=\frac{2n_{BB}+n_{AB}}{2n}.
$$
It is the sample proportion among the $2n$ sampled alleles, so it is consistent and
$$
\sqrt n(\widehat\theta-\theta)
\xrightarrow{d}N\left(0,\frac{\theta(1-\theta)}2\right).
$$