Worked example
Worked example: 320 AA, 160 Aa, 20 aa. N = 500, p = (640+160)/1000 = 0.8, q = 0.2. Expected: 320, 160, 20 at equilibrium; the chi-square then tests how far your counts actually sit from those numbers.
The formula
The formulae: p² + 2pq + q² = 1 (Hardy-Weinberg, 1908), with p = (2×AA + Aa)/(2N) from observed counts and the χ² goodness-of-fit test at one degree of freedom.
What does equilibrium mean here?
In a large, randomly mating population with no selection, mutation, migration or drift, allele frequencies stay constant and genotypes settle to p², 2pq, q².
Why one degree of freedom?
Three genotype classes minus one for the total minus one because p was estimated from the data leaves one degree of freedom.
Can I enter frequencies instead of counts?
This version takes counts so it can run the chi-square. If you only know frequencies, multiply by any common sample size to approximate.