# Hardy-Weinberg Equilibrium Calculator for 2 Alleles

Hardy-Weinberg equilibrium is the expected frequencies of genotypes if mating is non-assortative and there are no mutations from one allele to another. When there are two alleles for a particular gene--A and B--and their respective population frequencies are p and q, then the expected frequencies of the genotypes AA, AB, and BB

AA = p²,     AB = 2pq,    BB = q²

### Hardy-Weinberg 2-Allele Calculator

 Genotypes AA AB BB Observed Expected   H-W Freq.
 P-Value =

Allele Frequencies.        A =       B =

To use the calculator above, enter the observed frequencies of the 3 different genotypes. The calculator will compute the frequency of each allele and the Hardy-Weinberg equilibrium expected frequencies of each genotype. It will also output the chi-square value so you can decide whether to reject or accept the null hypothesis that the population is at H-W equilibrium.

### Explanation of H-W Formula and Example

If there are two alleles for a particular gene (A and B) and their frequencies are p and q, then p + q must equal 1. This also implies that

(p + q)² = 1

as well. If you expand the terms of (p + q)², you get 3 differnt terms:

p²,  2pq,  q²

In non-assortative mating, where individuals do not have a mating preference for certain genotypes, the expected frequencies of the 3 genotypes correspond to the 3 terms of the equation above.

Example 1: Suppose the frequencies of the alleles A and B in a certain population are 0.7 and 0.3 respectively. If individuals have no genotype preference when mating and there is no significant level of allele mutation, then the expected frequencies of the genotypes AA, AB, and BB are

AA: (0.7)(0.7) = 0.49
AB: 2(0.7)(0.3) = 0.42
BB: (0.3)(0.3) = 0.09

Example 2: Suppose you know the genotype frequencies for a 2-allele gene in a certain population that contains 420 individuals:

AA: 207 individuals
AB: 160 individuals
BB: 53 individuals

From this information you can first compute the frequencies of each allele A and B:

A: (2*207 + 160)/(2*420) = 0.6833
B: (2*53 + 160)/(2*420) = 0.3167

Now we can compute the expected number of individuals that would have each genotype if the population were at Hardy-Weinberg equilibrium:

AA: (0.6833)(0.6833)420 = 196.1
AB: 2(0.6833)(0.3167)420 = 181.78
BB: (0.3167)(0.3167)420 = 42.12

We can perform a chi-square test test on the observed and expected values to see if the observational data supports the hypothesis that the population is at H-W equilibrium for the gene.

In Hardy-Weinberg chi-square analysis, the number of degrees of freedom is equal to the number of genotypes minus the number of alleles. In this case, 3 - 2 = 1, so we use the chi-square distribution with 1 degree of freedom.

In general, if the number of alleles is n, then the number of genotypes is n(n+1)/2. Thus, the number of degrees of freedom is

d.f. = n(n+1)/2 = n = n(n-1)/2