Hardy Weinberg Calculator

Hardy Weinberg Calculator

Hardy–Weinberg Calculator

Calculate allele frequencies, genotype frequencies, and expected genotype counts.

Choose the value you already know.
Enter a proportion from 0 to 1, not a percentage.
Used to estimate expected genotype counts.
Homozygous dominant genotype.
Heterozygous genotype.
Homozygous recessive genotype.

Your Hardy–Weinberg Results

p + q = 1   |   p² + 2pq + q² = 1
p
Allele A
q
Allele a
p² (AA)
Homozygous dominant
2pq (Aa)
Heterozygous
q² (aa)
Homozygous recessive

Frequencies are proportions of the population or gene pool. Multiply a genotype frequency by population size to estimate expected individuals. Expected values can be fractional because they are statistical expectations.

The Hardy–Weinberg Equations

p + q = 1
p² + 2pq + q² = 1

p and q are the frequencies of two alleles. Under the model, p² is the expected AA frequency, 2pq is the expected Aa frequency, and q² is the expected aa frequency.

These equations describe expected genotype proportions under Hardy–Weinberg assumptions. A calculation alone does not prove that a real population is in equilibrium.

Hardy Weinberg Calculator: Calculate Allele and Genotype Frequencies

The Hardy–Weinberg principle is a foundational concept in population genetics. It provides a mathematical model for predicting genotype frequencies from allele frequencies in a population under a specific set of assumptions. Students use it in biology classes, AP Biology, undergraduate genetics, and evolutionary biology to understand how genetic variation is distributed within populations.

Our Hardy–Weinberg Calculator helps you calculate allele frequencies, expected genotype frequencies, and expected genotype counts. You can start with a known allele frequency, use the frequency of a recessive genotype, or enter observed genotype counts to estimate allele frequencies and compare observed counts with expected values.

The calculator is intended as an educational tool for students, instructors, and anyone learning population genetics. Its results are based on the standard two-allele Hardy–Weinberg model. A real population may not satisfy all of the model's assumptions, so the calculations should be interpreted in the context of the biological question being studied.

Table of Contents

What Is the Hardy Weinberg Principle?

The Hardy–Weinberg principle describes a theoretical population in which allele and genotype frequencies remain constant from one generation to the next when specific evolutionary and mating conditions are met.

The principle is associated with mathematician Godfrey Harold Hardy and physician Wilhelm Weinberg, who independently described the relationship between allele frequencies and genotype frequencies in the early twentieth century.

In a simplified model, consider a gene with two alleles, A and a. Let p represent the frequency of allele A and q represent the frequency of allele a. If these are the only two alleles at the locus, their frequencies must add up to one.

The allele-frequency equation is:

p + q = 1

Under Hardy–Weinberg equilibrium, the expected genotype frequencies are:

p² + 2pq + q² = 1

The three terms represent the expected proportions of three possible genotypes:

  • p²: Homozygous dominant genotype AA.
  • 2pq: Heterozygous genotype Aa.
  • q²: Homozygous recessive genotype aa.

These equations are useful because allele frequencies can be used to predict genotype proportions under the model. Researchers and students can then compare those predictions with observed data.

Hardy Weinberg Calculator

What Does the Hardy Weinberg Calculator Do?

The calculator provides two main workflows.

1. Calculate frequencies from a known value

If you know the frequency of allele A, allele a, or the homozygous recessive genotype, the calculator derives the remaining frequencies using the Hardy–Weinberg equations.

For example, if the recessive genotype frequency is 0.09, then q² = 0.09. Taking the square root gives q = 0.30, and p = 1 − q = 0.70. The expected genotype frequencies are 0.49 for AA, 0.42 for Aa, and 0.09 for aa.

This approach is often used in classroom questions that provide the percentage of a population expressing a recessive phenotype.

2. Calculate from observed genotype counts

If you know the numbers of individuals with genotypes AA, Aa, and aa, the calculator estimates the allele frequencies directly from those counts.

It also calculates the genotype frequencies expected under Hardy–Weinberg equilibrium and displays a comparison between observed and expected counts. A basic chi-square statistic and approximate p-value are provided as an introductory screening aid.

Statistical interpretation requires care. Small expected counts, sampling design, population structure, and other factors can affect the validity of a chi-square test. The calculator is not a substitute for a study-specific statistical analysis.

How to Use the Hardy–Weinberg Calculator

Method 1: Start with a known allele or genotype frequency

  1. Select From Allele / Recessive Frequency.
  2. Choose the value you know: p, q, or q².
  3. Enter the frequency as a decimal between 0 and 1.
  4. Optionally enter the population size if you want expected genotype counts.
  5. Select Calculate Frequencies.

The calculator returns p, q, p², 2pq, and q², along with their percentage equivalents. If you entered a population size, it also estimates the expected number of individuals in each genotype category.

For example, a frequency of 0.30 means 30%, while a frequency of 0.03 means 3%. Entering 30 instead of 0.30 would be invalid because the tool expects a proportion, not a percentage.

Method 2: Start with genotype counts

  1. Select From Genotype Counts.
  2. Enter the observed number of individuals with genotype AA.
  3. Enter the observed number with genotype Aa.
  4. Enter the observed number with genotype aa.
  5. Select Calculate and Compare.

The calculator adds the three genotype counts to determine the sample size. It estimates allele frequencies, calculates expected genotype counts, and reports a chi-square statistic with an approximate p-value.

The expected counts do not have to be whole numbers. They represent model-based expectations rather than a prediction of the exact genotype of every individual.

Understanding Allele Frequencies: p and q

An allele frequency is the proportion of all copies of a particular allele at a gene locus in the population's gene pool.

In the two-allele model, p is the frequency of allele A and q is the frequency of allele a.

Because the two alleles account for all copies at the locus:

p + q = 1

If p = 0.70, then q = 1 − 0.70 = 0.30. The population's allele frequencies are therefore 70% for A and 30% for a.

In a diploid population, each individual typically has two copies of the locus, one inherited from each parent. An individual with genotype AA carries two A alleles, an individual with genotype Aa carries one A and one a allele, and an individual with genotype aa carries two a alleles.

Allele frequencies are not the same as genotype frequencies. For example, an allele frequency of 0.70 does not mean that 70% of individuals must have genotype AA. The expected genotype frequency depends on the Hardy–Weinberg model and is calculated using p², 2pq, and q².

Understanding Genotype Frequencies: p², 2pq, and q²

The Hardy–Weinberg genotype equation is:

p² + 2pq + q² = 1

Each term corresponds to one of the three possible genotypes for a diploid locus with two alleles.

Homozygous dominant: p²

The genotype AA contains two copies of allele A. Under the model, its expected frequency is p × p, or p².

If p = 0.70:

p² = 0.70 × 0.70 = 0.49

The expected AA frequency is 0.49, or 49%.

Heterozygous: 2pq

The genotype Aa contains one copy of each allele. Under random pairing of alleles, the A-a and a-A combinations contribute to the heterozygote frequency, giving 2pq.

If p = 0.70 and q = 0.30:

2pq = 2 × 0.70 × 0.30 = 0.42

The expected Aa frequency is 0.42, or 42%.

Homozygous recessive: q²

The genotype aa contains two copies of allele a. Under the model, its expected frequency is q × q, or q².

If q = 0.30:

q² = 0.30 × 0.30 = 0.09

The expected aa frequency is 0.09, or 9%.

Adding the three genotype frequencies gives:

0.49 + 0.42 + 0.09 = 1.00

This confirms that the expected proportions account for the full population under the two-allele model.

Worked Example: A Population with p = 0.7 and q = 0.3

Suppose a population has an A allele frequency of 0.70 and an a allele frequency of 0.30.

The first step is to confirm the allele-frequency equation:

p + q = 0.70 + 0.30 = 1.00

Next, calculate the expected genotype frequencies.

GenotypeCalculationExpected frequencyPercentage
AAp² = 0.70²0.4949%
Aa2pq = 2 × 0.70 × 0.300.4242%
aaq² = 0.30²0.099%
Totalp² + 2pq + q²1.00100%

If the population contains 1,000 individuals, the expected counts are:

  • AA: 0.49 × 1,000 = 490 individuals.
  • Aa: 0.42 × 1,000 = 420 individuals.
  • aa: 0.09 × 1,000 = 90 individuals.

These values are expected counts under the model. Actual observed counts may differ because of sampling variation or biological processes that cause a population to depart from the assumptions.

Calculating Allele Frequency from Genotype Counts

When genotype counts are available, you can calculate allele frequencies directly.

Let:

  • AA be the number of homozygous dominant individuals.
  • Aa be the number of heterozygous individuals.
  • aa be the number of homozygous recessive individuals.
  • N be the total number of individuals, so N = AA + Aa + aa.

Each individual contributes two alleles to the gene pool. The total number of allele copies is therefore 2N.

The allele A frequency is:

p = (2 × AA + Aa) ÷ (2N)

The allele a frequency is:

q = (2 × aa + Aa) ÷ (2N)

The homozygous individuals contribute two copies of their respective alleles, while each heterozygous individual contributes one copy of each allele.

For example, suppose a sample contains 490 AA individuals, 420 Aa individuals, and 90 aa individuals. The total sample size is 1,000.

The A allele frequency is:

p = (2 × 490 + 420) ÷ 2,000 = 1,400 ÷ 2,000 = 0.70

The a allele frequency is:

q = (2 × 90 + 420) ÷ 2,000 = 600 ÷ 2,000 = 0.30

The allele frequencies are p = 0.70 and q = 0.30. The expected genotype frequencies under Hardy–Weinberg equilibrium are consequently 0.49, 0.42, and 0.09.

Estimating Allele Frequency from a Recessive Phenotype

Some genetics questions provide the proportion of a population that expresses a recessive phenotype instead of giving allele frequencies directly.

For a simple, fully recessive trait at a two-allele locus, the recessive phenotype corresponds to genotype aa. Under Hardy–Weinberg equilibrium, its expected frequency is q².

If 9% of the population expresses the recessive phenotype:

q² = 0.09

Take the square root:

q = √0.09 = 0.30

Then calculate the other allele frequency:

p = 1 − q = 0.70

Finally, calculate the expected genotype frequencies:

  • AA: p² = 0.49, or 49%.
  • Aa: 2pq = 0.42, or 42%.
  • aa: q² = 0.09, or 9%.

This method is useful in educational problems, but it relies on important assumptions. The observed phenotype must accurately identify the homozygous recessive genotype, the relevant locus must be appropriately modeled with two alleles, and the inference assumes Hardy–Weinberg proportions. Dominant phenotypes generally cannot be used in the same direct way to distinguish AA from Aa without additional information.

What Is Hardy Weinberg Equilibrium?

A population is described as being in Hardy–Weinberg equilibrium at a locus when its allele and genotype frequencies match the model's expectations under the relevant assumptions.

The standard model assumes:

  1. A very large population, so genetic drift is negligible.
  2. Random mating with respect to the locus.
  3. No mutation that changes the allele frequencies.
  4. No migration or gene flow that changes the population's allele frequencies.
  5. No natural selection favoring particular genotypes.

These are simplifying assumptions, not a claim that real populations are perfectly isolated from every evolutionary process. Natural populations can experience selection, migration, mutation, genetic drift, nonrandom mating, population structure, and other influences.

The Hardy–Weinberg model is valuable because it provides a baseline. If observed genotype frequencies differ from the expected values, researchers can investigate possible explanations. A deviation does not, by itself, identify which biological process caused it.

Comparing Observed and Expected Genotype Counts

If you have observed genotype counts, the calculator can compare them with the expected counts generated from estimated allele frequencies.

A common introductory method is the chi-square statistic:

χ² = Σ (Observed − Expected)² ÷ Expected

The calculation is performed for each genotype category and the results are added. For the usual two-allele Hardy–Weinberg test with allele frequencies estimated from the observed counts, an introductory chi-square test commonly uses one degree of freedom.

The p-value helps assess whether the observed discrepancy would be unusual under the test's assumptions. A small p-value, often compared with a threshold of 0.05, suggests that the observed counts differ from the expected proportions more than the model would commonly predict under the null hypothesis.

However, a p-value does not measure the probability that the population is in equilibrium. A non-significant result does not prove equilibrium, and a significant result does not tell you which evolutionary mechanism is responsible.

The standard chi-square approximation may also be unreliable when expected counts are small. In those situations, a researcher may need an exact test or another method appropriate to the study design.

Common Mistakes When Using the Hardy Weinberg Equation

1. Confusing allele frequencies with genotype frequencies

p and q describe allele frequencies, whereas p², 2pq, and q² describe expected genotype frequencies. They refer to different quantities and should not be used interchangeably.

2. Entering percentages as whole numbers

The calculator expects a proportion between 0 and 1. Enter 0.09 for 9%, not 9.

3. Forgetting to take the square root of q²

If the recessive genotype frequency is 0.09, q is 0.30—not 0.09. The correct operation is q = √q².

4. Assuming every population is in equilibrium

The Hardy–Weinberg principle is a model with defined assumptions. A population may deviate from the expected proportions because of evolutionary forces, population structure, sampling effects, or violations of the model.

5. Treating expected counts as exact observations

Expected counts are calculated from frequencies and sample size. They can be fractional and may not match the actual observed counts.

6. Interpreting a chi-square result as proof

A statistical test provides evidence relative to a model and its assumptions. It does not prove that a population is or is not evolving, nor does it identify the cause of a deviation on its own.

Hardy Weinberg Calculator

Frequently Asked Questions

1. What is the Hardy–Weinberg equation?

The allele-frequency equation is p + q = 1, and the genotype-frequency equation is p² + 2pq + q² = 1. They describe the relationship between two allele frequencies and the expected genotype frequencies in a diploid population under the model.

2. What do p and q represent?

p is the frequency of one allele, commonly labeled A, and q is the frequency of the other allele, commonly labeled a. For a two-allele locus, their frequencies sum to one.

3. What do p², 2pq, and q² represent?

They are the expected frequencies of AA, Aa, and aa, respectively, under Hardy–Weinberg equilibrium.

4. How do I calculate q from q²?

Take the square root of q². For example, if q² = 0.09, then q = √0.09 = 0.30.

5. How do I calculate allele frequencies from genotype counts?

Calculate p = (2AA + Aa) ÷ 2N and q = (2aa + Aa) ÷ 2N, where N is the total number of individuals. The two allele frequencies should add up to one, subject to rounding.

6. Can I use the calculator for AP Biology?

Yes. The tool covers the standard allele-frequency and genotype-frequency calculations commonly taught in introductory population genetics, including p + q = 1 and p² + 2pq + q² = 1.

7. What conditions are required for Hardy–Weinberg equilibrium?

The standard model assumes a very large population, random mating, and no mutation, migration, or natural selection at the locus. Real populations may not meet all these assumptions.

8. Does a population that matches the equation prove evolution is not occurring?

No. A close match to expected frequencies does not prove that every assumption is satisfied or that no evolutionary processes are acting. Statistical power, sampling, and the particular locus all matter.

9. What does a significant chi-square result mean?

It suggests that the observed genotype counts differ from the expected counts more than would commonly be expected under the statistical model and assumptions. It does not identify the cause of the difference.

10. Can the calculator estimate the number of carriers?

For the simple two-allele recessive model, the expected heterozygote frequency is 2pq. If you provide a population size, the calculator estimates the expected number of heterozygous individuals by multiplying 2pq by that population size. This is a model-based estimate, not a clinical carrier assessment.

11. Can Hardy–Weinberg calculations be used for genes with more than two alleles?

The standard p + q and p² + 2pq + q² equations describe a locus with two alleles. A locus with three or more alleles requires a generalized model with additional allele and genotype terms.

12. Is the Hardy–Weinberg Calculator free?

Yes. The calculator on this page is designed for free educational use and runs directly in the browser.

Conclusion

The Hardy–Weinberg principle provides a useful mathematical baseline for understanding allele and genotype frequencies in population genetics. With p + q = 1 and p² + 2pq + q² = 1, you can estimate expected genotype proportions from allele frequencies or infer allele frequencies from genotype counts.

Use the calculator to check classroom exercises, explore example populations, and compare observed counts with model-based expectations. For research or formal statistical work, confirm that the model and test assumptions fit your data and consult an appropriate statistical method.

Disclaimer: This calculator is intended for educational and informational purposes. Its results depend on the inputs and assumptions of the two-allele Hardy–Weinberg model. The output does not establish that a real population is in equilibrium and should not be treated as a substitute for a study-specific statistical analysis.

References

  1. OpenStax — Biology 2e: Population Evolution
    Explains the Hardy–Weinberg principle, its assumptions, and the relationship between allele and genotype frequencies.
    https://openstax.org/books/biology-2e/pages/19-1-population-evolution
  2. OpenStax — Concepts of Biology: Discovering How Populations Change
    Introduces population genetics and describes the evolutionary processes that can change allele frequencies.
    https://openstax.org/books/concepts-biology/pages/11-1-discovering-how-populations-change
  3. Duke University — Hardy–Weinberg Problem Solver
    An educational resource for working with observed genotype counts, allele frequencies, and expected Hardy–Weinberg proportions.
    https://genevol.biology.duke.edu/pc/hw
  4. Pearson — Allele Frequency Calculator
    A learning resource showing methods for deriving allele frequencies from genotype data or recessive phenotype frequencies.
    https://www.pearson.com/channels/calculators/allele-frequency-calculator

Reference note: These resources support the mathematical and biological concepts described here. The calculator on this page is an educational implementation and may not reproduce every statistical feature or interpretation offered by other tools.

About Smith Ghule

Hi, I’m Smith Ghule — a passionate cricket enthusiast and technology professional from Pune, Maharashtra. I have been working in the IT industry since 2015, gaining experience across various domains in technology and operations. Alongside my professional journey, I closely follow cricket and enjoy staying updated with the latest developments in both the sports and tech worlds. My interests lie in combining analytical thinking, innovation, and continuous learning to grow personally and professionally.

View all posts by Smith Ghule →