Consider two alleles at the A locus, A1 and A2. Let their frequencies be p and q, respectively (p and q are each between 0 and 1). Imagine a thought experiment:
• Pick an allele at random from the gene pool. There is a chance p that it is A1 and a chance q that it is A2.
• We put the first allele back into the pool and then make a second pick at random. Again, the chance of picking A1 is p and the chance of picking A2 is q.
It follows that:
• The chance that both alleles were A1 is p2.
• The chance that both alleles were A2 is q2.
• The chance that the first allele was A1 and the second A2 is pq. The chance that the first was A2 and the second A1 is qp. Overall, the chance of picking one A1 and one A2 allele is 2pq.
If we pick a person at random from the population, this is equivalent to picking two alleles at random from the gene pool. Staying with our alleles A1 and A2, the chance that the person is A1A1 is p2, the chance that they are A1A2 is 2pq, and the chance that they are A2A2 is q2. This simple relationship between allele frequencies and genotype frequencies is called the Hardy–Weinberg distribution. It holds whenever a person’s two alleles are drawn independently and at random from the gene pool. Note that the Hardy Weinberg relationship is a distribution; it is a common student error to suppose it is the equation p2 + 2pq + q2 = 1. That equation is only true if A1 and A2 are the only alleles at the locus, so that p + q = 1. There was nothing in our thought experiment to say that should be so. There might have been all manner of other alleles; the frequencies of the A1A1, A1A2, and A2A2 genotypes would still hold; just, there would be other genotypes as well.
The Hardy–Weinberg distribution provides an important check on population genotyping data. If a random sample of unrelated individuals from a population has been genotyped, the first check on the data is to see whether the types follow the Hardy Weinberg distribution. Consider, for example, the data in Box 12.1.

If the observed distribution is significantly different from the Hardy–Weinberg expectation, there are a number of possible explanations:
• Genotyping errors—maybe some heterozygotes are being missed, and misclassified as homozygotes. Check using an independent technique.
• Population stratification—maybe the population is not homogeneous but comprises two or more relatively isolated subpopulations. In the example in Box 12.1, might the sample have been taken in Xinjiang province, where the large ethnic Uighur population interbreed rather little with Han Chinese brought in by mass immigration? Each may within itself be in Hardy–Weinberg equilibrium, but with different allele frequencies.
• Loss of specific genotypes before sampling—for example, if the character being studied were a serious autosomal recessive disease, affected homozygotes might have been present at birth in the expected proportion, but many might have died before the adult population was sampled.
• Inbreeding—if many couples in a population are consanguineous (blood relatives), when we consider the genotypes of their children, one of the prerequisites of the random-picking model we used to establish the Hardy–Weinberg distribution is violated. The second allele is not completely independent of the first because relatives share genes more than expected by chance. The effect is to increase the proportion of both homozygous genotypes and decrease the proportion of hetero zygotes, compared to the Hardy–Weinberg expectation.
Note that when the chi-squared test shows no significant deviation from the Hardy Weinberg expectation, this does not necessarily mean that none of the above forces is acting; it merely means that if any is acting, it is not sufficiently strong to produce a clear deviation, given the number of individuals tested. Statistically the chi-squared test has quite low power to detect deviations.