Hardy-Weinberg Calculator

Enter any one frequency or your observed genotype counts to get p, q, p², 2pq and q², expected counts and a chi-square test for Hardy-Weinberg equilibrium, with every step.

Free, no sign-upRuns in your browserUpdated November 2026
Counts of individuals of each genotype in your sample. Allele frequencies are estimated from them and tested against HWE.
Allele frequencies
—
GenotypeFrequencyExpectedObserved
χ² (df = 1)
—
p-value
—
Step-by-step working
    Genotype frequencies across all values of p

    How to use the Hardy-Weinberg Calculator

    1. Choose what you know: genotype counts from a sample, or one frequency such as p, q, p², 2pq, q² or the recessive phenotype frequency.
    2. Enter the numbers. Frequencies can be typed as a decimal, a percentage, a fraction or "1 in N"; add a population size to get expected counts.
    3. Read p, q and the genotype frequencies p², 2pq and q² with expected counts in the table.
    4. With counts, check the χ² test (df = 1): a p-value below 0.05 means the sample departs significantly from Hardy-Weinberg equilibrium.
    5. Open the step-by-step working to copy the method into your notes or exam answer.

    The Hardy-Weinberg principle

    The Hardy-Weinberg principle states that in a large, randomly mating population with no evolutionary forces acting, allele and genotype frequencies stay constant from generation to generation. The population is then in Hardy-Weinberg equilibrium (HWE), also called genetic equilibrium. It was described independently by G. H. Hardy and Wilhelm Weinberg in 1908.

    For one gene with two alleles, A (frequency p) and a (frequency q):

    p + q = 1 (p + q)² = p² + 2pq + q² = 1 p² = frequency of AA (homozygous dominant) 2pq = frequency of Aa (heterozygous) q² = frequency of aa (homozygous recessive) From genotype counts: p = (2·AA + Aa) ÷ 2N, q = 1 − p Expected counts: Np², 2Npq, Nq² Goodness of fit: χ² = Σ (O − E)² ÷ E, df = 1

    The equilibrium assumes a large population, random mating, and no mutation, migration or natural selection.

    Class 12 NCERT context

    In the NCERT Class 12 Biology chapter Evolution, the Hardy-Weinberg principle is used to explain what evolution means in genetic terms. The total genes and their alleles in a population form the gene pool, and the sum of all allelic frequencies is 1. NCERT writes the principle as p² + 2pq + q² = 1, the binomial expansion of (p + q)². When the measured frequencies differ from the expected values, the difference indicates the extent of evolutionary change. NCERT lists five factors that disturb the equilibrium:

    • Gene migration or gene flow – alleles enter or leave with migrating individuals.
    • Genetic drift – chance changes in frequency, strongest in small populations; the founder effect is one example.
    • Mutation – creates new alleles.
    • Genetic recombination – during gametogenesis.
    • Natural selection – some genotypes leave more offspring.

    The notation (p for the dominant allele, q for the recessive allele) and the reasoning on this page follow NCERT conventions.

    Worked example 1: from the recessive phenotype

    A recessive condition affects 1 in 10,000 people. Only aa individuals show it, so q² = 0.0001.

    • q = √0.0001 = 0.01; p = 1 − 0.01 = 0.99.
    • Carriers: 2pq = 2 × 0.99 × 0.01 = 0.0198, about 1 in 50.5 people.

    The striking point: although only 1 in 10,000 is affected, roughly 2% of people carry the allele, so most copies of a rare recessive allele are hidden in heterozygotes.

    Worked example 2: testing a sample with χ²

    A sample of 1,000 individuals contains 380 AA, 440 Aa and 180 aa.

    • p = (2 × 380 + 440) ÷ 2,000 = 1,200 ÷ 2,000 = 0.6; q = 0.4.
    • Expected: AA = 1,000 × 0.36 = 360, Aa = 1,000 × 0.48 = 480, aa = 1,000 × 0.16 = 160.
    • χ² = (380 − 360)² ÷ 360 + (440 − 480)² ÷ 480 + (180 − 160)² ÷ 160 = 1.111 + 3.333 + 2.5 = 6.944.
    • df = 3 classes − 1 − 1 estimated parameter = 1. The critical value at 5% is 3.841, and the exact p-value is about 0.0084.

    Because 6.944 > 3.841, the sample deviates significantly from HWE: there are fewer heterozygotes than expected, which can point to inbreeding, population substructure or genotyping error.

    Interpreting the χ² test

    χ² (df = 1)p-valueConclusion at 5%
    ≤ 3.841≥ 0.05No significant deviation from HWE
    > 3.841< 0.05Significant deviation from HWE
    > 6.635< 0.01Significant at the 1% level

    This calculator computes the p-value exactly from the χ² distribution (the regularized incomplete gamma function), not from a lookup table. If any expected count is below 5 the χ² approximation becomes unreliable and an exact test is preferred.

    Common mistakes

    • Taking q from the carrier frequency. Start from the homozygous recessive (aa) frequency, which equals q². The dominant phenotype is p² + 2pq, not p².
    • Forgetting the square root. If q² = 0.16, then q = 0.4, not 0.16.
    • Counting individuals instead of alleles. Each individual carries two alleles, so divide by 2N.
    • Using df = 2. One degree is lost because p is estimated from the same data.

    Exam tips (Class 12 and NEET)

    • Write both equations first: p + q = 1 and p² + 2pq + q² = 1.
    • 2pq is largest (0.5) when p = q = 0.5.
    • Learn the five disturbing factors in NCERT's order; they are frequently asked as one-mark questions.

    For crosses between two parents, use the Punnett square calculator.

    Frequently asked questions

    What is the Hardy-Weinberg equation?
    p² + 2pq + q² = 1, together with p + q = 1. Here p and q are the frequencies of the two alleles, and p², 2pq and q² are the frequencies of the AA, Aa and aa genotypes in a population at equilibrium.
    How do you find q from the recessive phenotype?
    Individuals with the recessive phenotype are aa, so their frequency is q². Take the square root: if 16% show the recessive trait, q² = 0.16, so q = 0.4 and p = 0.6.
    What are the five factors that affect Hardy-Weinberg equilibrium?
    NCERT Class 12 lists gene migration (gene flow), genetic drift, mutation, genetic recombination and natural selection. Any of them can change allele frequencies and so cause evolution.
    How do you test if a population is in Hardy-Weinberg equilibrium?
    Estimate p from the genotype counts, calculate expected counts Np², 2Npq and Nq², and compute χ² = Σ (O − E)² ÷ E with 1 degree of freedom. A χ² above 3.841 (p-value below 0.05) indicates a significant deviation.
    Why is the degree of freedom 1 in the Hardy-Weinberg chi-square test?
    There are three genotype classes, giving 2 degrees of freedom, and one more is lost because the allele frequency p is estimated from the same data, leaving 1.
    What does 2pq represent?
    The frequency of heterozygotes (Aa). For a recessive disease these are the unaffected carriers, and they usually far outnumber affected people when the allele is rare.

    Last reviewed November 2026. Results are estimates for information only — see our disclaimer.