Hardy Weinberg Population Genetics

Hardy Weinberg Population Genetics

Subject: Biology
Time: 1-2 Class periods (45 minutes each)

High School AP/IB Biology


Biology students will use the Hardy Weinberg Classroom Model Net Logo program created by Kenneth Letendre. They will use the computer simulation to analyze how variables such as the proportion of alleles, population size, and selection against alleles can influence the genetics of a population. The Hardy Weinberg principle predicts the genotype and phenotype frequencies given that five assumptions (large population size, mating is random, no mutations, no migration, and no selection) hold true in a population.


Students should have been introduced to the Hardy Weinberg Principle before starting this lesson.


Materials and Tools

NetLogo Home Page: http://ccl.northwestern.edu/netlogo/

NetLogo Hardy Weinberg Simulation, http://ccl.northwestern.edu/netlogo/models/community/HardyWeinbergClassroomModel



Students will complete the lab worksheet.  The objectives of the lesson will be assessed by reviewing student answers on the lab worksheet.

Note: Ami Lefevre, lead CT-STEM teacher, adapted materials from Kenneth Letendre’s Hardy-Weinberg Classroom Model (2009) to develop the handouts below.

Compatible With




chrome books



What's Next?


Next Generation Science Standards
  • Life Science
    • [HS-LS3] Heredity: Inheritance and Variation of Traits
    • [HS-LS4] Biological Evolution: Unity and Diversity

Computational Thinking in STEM
  • Modeling and Simulation Practices
    • Using Computational Models to Find and Test Solutions
    • Using Computational Models to Understand a Concept
  • Computational Problem Solving Practices
    • Assessing Different Approaches/Solutions to a Problem
  • Data Practices
    • Analyzing Data
    • Collecting Data
    • Creating Data
    • Manipulating Data
  • Systems Thinking Practices
    • Investigating a Complex System as a Whole
    • Thinking in Levels
    • Understanding the Relationships within a System

Comments, Feedback, and Quesitons

Hardy Weinberg Population Genetics

Teacher Notes

Background (The following adapted from the Netlogo Hardy Weinberg Model site.)

The HW principle predicts the genotypic frequencies that will be observed in a population over the course of generations given particular allele frequencies, and given that five assumptions (discussed below) hold true in the population. Given two alleles, A and a, and the frequencies of each allele in the population, freq(A)=p and freq(a)=q, the HW principle predicts:

1) p + q = 1.

That is, since A and a are the only alleles at this locus in the model population, the allelic frequencies of A and a must add up to 1.


2) The genotypic frequency of AA homozygotes in the population is p^2.

The frequency of aa homozygotes is q^2. The probability that any given member of the population will inherit two A alleles is p x p.


The frequency of heterozygotes is 2pq. The probability that any given member of the population will inherit one A and one a allele is p x q x 2, since a heterozygote can inherit allele A from its mother and allele a from its father, OR allele a from its mother and A from its father. p^2 + 2pq + q^2 = 1. That is, the frequencies of both types of homozygotes and the frequency of heterozygotes must add up to 1, since these are the only possible combinations.

These predictions hold true given these five assumptions:

  1. Large (infinite) population size.In small populations, chance differences in reproductive success and mating choices can produce deviations from the predictions of HW.

  2. No selection. There is no systematic difference in the survival or reproductive success of organisms with different genotypes.

  3. No mutation. The alleles are inherited from one generation to the next without being changed by mutation.

  4. No migration. No organisms leave the population, and no new ones come in.

  5. Random mating. Organisms choose mates at random with respect to the alleles of interest in the model.


If any of these assumptions do not hold true in a population, the observed genotypic frequencies will deviate from the predictions of HW in particular ways depending on the assumption(s) that is (are) violated.

NetLogo is a programmable modeling environment for simulating natural and social phenomena. It was authored by Uri Wilensky in 1999 and has been in continuous development ever since at the Center for Connected Learning and Computer-Based Modeling. NetLogo is particularly well suited for modeling complex systems developing over time. Modelers can give instructions to hundreds or thousands of "agents" all operating independently. This makes it possible to explore the connection between the micro-level behavior of individuals and the macro-level patterns that emerge from the interaction of many individuals.

The Netlogo HW model is initialized with a randomly distributed population of blue (the dominant trait) and yellow (the recessive trait) organisms. Organisms are randomly assigned alleles according to the selected frequency of the A allele (the frequency of the a allele is determined as q = p - 1.)

As the model runs, organisms move around the world in a correlated random walk at a dispersal rate determined by the user. On each tick, organisms select a mate, either by mating with another organism chosen at random anywhere in the world, or by choosing a nearby organism to mate with. An offspring is produced adjacent to the reproducing organism, which randomly inherits either the a or A alleles from each of its parents. The organisms are diploid, but are essentially hermaphroditic, as every organism is capable of producing offspring and may mate with any other organism without the need to locate a mate of the opposite sex.

Following reproduction, the population decreases to bring the population size back down to the carrying capacity determined by the user. During each population decrease, each organism is subject to a probability of death determined by the degree to which the current population size exceeds the carrying capacity. As a result, an organism may live for several generations, or it may not survive to first reproduction. There is no maturation time, so that any organism that survives the first drop in population size following its birth can reproduce during the next reproduction cycle.

The model ends when it reaches a specified number of generations ("ticks"), or when one allele becomes fixed in the population (that is, the other allele goes extinct), or when the entire population of organisms goes extinct (e.g. due to high selection against both phenotypes).


How to use the Netlogo HW Model:

The "proportion-allele-A" slider bar determines the initial frequency of the allele A. The frequency of allele a is determined by calculating freq(a) = 1 - freq(A). The "population-size" slider determines the carrying capacity of the system. The "species" chooser allows the user to select from a list of possible icons to represent the organism as they move around the world.

Clicking the "setup" button initializes the world with a population of organisms of the selected species, with the specified allele frequencies. The "go" button starts the model.

The "Population size" monitor displays the current population size. Note that this population size will not always match exactly the value selected by the "population-size" slider. In fact, during each reproduction cycle, the population size will rise well above this value, and then fall back roughly to the specified population size at the end of the culling cycle. However because mortality for each organism is determined by a certain probability, the final population size will not be exactly the specified value, although it will be close.

Graphs track the genotypic frequencies, phenotypic frequencies, and allele frequencies over time as the model runs. Monitors display the current values for each of these.

As the model runs, the user may change the settings of any slider, chooser or input -- with the exception of the "proportion-allele-A" slider -- and the model will reflect these newly selected values. The value of the "proportion-allele-A" slider is used only at model setup; allele frequencies are determined only by the behavior of the organisms after the model begins running.


Teaching Notes

Before the activity teachers should read the background information about population genetics and the Hardy Weinberg principle. Teachers should also familiarize themselves with the Netlogo HW model and complete the handout to anticipate questions.

Things to notice about the Netlogo HW model:

Note that the genotypic and phenotypic frequencies approximate the values predicted by the HW formulas. Try calculating the predicted values based on the allele frequencies you have specified (or the current allele frequencies obtained by the current A and a alleles present in the population) and compare these to the actual values produced by the model as it runs. The model itself does not make use of the HW formulas, but produces values similar to those predicted by HW by the interactions of the model organisms.


Note the random changes in the genotypic, phenotypic, and allelic frequencies over time. These changes are more apparent with smaller population sizes, but can still be observed even with populations in the thousands. These random changes result from random differences in the survival and reproductive success of individuals each generation, and are called genetic drift. Genetic drift has a bigger effect on the makeup of small populations than larger ones. Theoretically, the HW assumption of "large population" actually requires an infinitely large population in order to completely eliminate the effect of drift.

Things to try:

Experiment with the settings of the model to create violations of the five assumptions described above. The Hardy-Weinberg equilibrium describes a theoretical population that cannot exist in the real world; perhaps its greatest value is in describing a population where no evolution is occurring, in order to better understand real populations where one or more of the five assumptions are violated, and evolution is occurring.


  1. Large (infinite) population size. Try running the model with populations of different sizes in order to observe differences in the strength of genetic drift.

  2. No selection. Try experimenting with different degrees of selection against (increased mortality of) the blue and yellow phenotypes. You will observe that selection against the recessive phenotype (yellow color) takes much longer to completely remove the a allele from the population, even with heavy selection against the yellow phenotype. Why is this? What does this tell us about the persistence of recessive genetic disorders in the population?

  3. No mutation. Experiment with different mutation rates from dominant to recessive, or recessive to dominant. What happens if there is a large rate of mutation in both directions?

  4. No migration. Experiment with different rates of immigration of blue and yellow individuals. How does immigration of individuals of a particular color effect the overall genetic makeup of the population?

  5. Random mating. The "mate-with" chooser can cause the organisms in the model to choose mates completely at random, selecting any other organism in the world as a mate.


You can also cause organisms to mate with a neighbor, so that organisms must be adjacent in order to mate with each other. Note what happens to the frequency of heterozygotes when organisms are mating with their neighbors. Also note that increasing the dispersal rate (the distance the organisms move each time step) decreases the effect of mating with neighbors on the phenotypic makeup of the population. Why does this happen?

Extending the model:

Other methods for violating the assumptions of the HW equilibrium could be added. For example, selection in this model is caused by increasing the mortality rate of one or both of the phenotypes. Selection could also result from differential reproductive output, or from differential success in finding mates (sexual selection).

The model could also be extended to multiple genes to, for example, examine the effect of linkage on inheritance.

Pre-class Preparation

Teachers should review the system requirements to run the NetLogo programs.  The requirements can be found at http://ccl.northwestern.edu/netlogo/docs