Example (preset)
Once you select an example, the input will be filled in and the results will appear immediately.
Inputs
Observed genotype counts (AA/Aa/aa)
Used only when df=2 is selected because the expected p is fixed outside the sample.
Allele frequency assumption (expected frequencies only)
Use this mode when p is assumed in advance and you only need expected genotype frequencies, not a χ² p-value.
Allele totals
Use this mode when the data source gives allele totals and you still want p, q, and expected genotype frequencies without a χ² p-value.
Advanced (display/graph)
Paste / CSV (optional)
It also supports pasting TSV/CSV (e.g.AA Aa aa). Once pasted, it will be reflected in the input field.
Results
—
*This is a statistical calculation tool and is not intended for medical judgment.
graph
*Residuals are displayed only in observed value mode (Advanced → "Show residuals").
Table (O/E/Contribution)
| genotype | observed(O) | expected(E) | O−E | (O−E)²/E | residual |
|---|
How to use/calculate
- Enter AA/Aa/aa (you can also use the example).
- Select degrees of freedom (default is df=1) and significance level (for display).
- p,q, expected frequency, χ², p-value are displayed.
Allele frequencies: p = (2AA + Aa) / (2N), q = 1 − p.
Expected counts under HWE: E(AA) = p²N, E(Aa) = 2pqN, E(aa) = q²N.
Chi-square statistic: Σ (O − E)² / E across AA, Aa, and aa.
If expected counts are small, the chi-square approximation can be unstable. Review the warning before interpreting the p-value.
Choose the input mode by the evidence you already have
- Use Observed genotype counts when you have AA, Aa, and aa counts from a sample and want χ² plus p-value.
- Use Allele frequency assumption when you already know p and only need expected genotype frequencies for planning or teaching.
- Use Allele totals when the dataset reports A and a copies instead of genotype counts.
Treat the df switch as part of the method. `df=1` matches the common case where p is estimated from the same sample. `df=2` is only for advanced workflows where the expected p is fixed independently before you compare counts.
Which genetics page should you use?
- Punnett square: start there when you need the expected ratio from one planned cross.
- Mendelian chi-square: use it when you already have offspring counts and want to test fit to a fixed inheritance ratio.
- Hardy-Weinberg: use this page when expected frequencies come from allele frequencies in a population sample.
- Wright-Fisher: move there when the real question is how allele frequencies drift over generations.
Frequently asked questions (FAQ)
What is Hardy-Weinberg equilibrium (HWE)?
With two alleles (A and a), Hardy-Weinberg predicts genotype frequencies from p and q. The expected frequencies are p² (AA), 2pq (Aa), and q² (aa) when the usual HWE assumptions are a reasonable approximation.
How do you calculate p and q?
From observed genotype counts, calculate p = (2AA + Aa) / (2N) and q = 1 − p. The page also derives q automatically when you start from p.
Why is df often equal to 1 for the chi-square test?
In the common workflow, p is estimated from the same sample that produced AA, Aa, and aa. That consumes one degree of freedom, so df=1 is usually the right interpretation. Use df=2 only when p was fixed independently before testing.
What should I do if expected counts are small?
Treat the chi-square p-value cautiously. Small expected counts can make the approximation weak, so review sample size, category balance, and whether an exact test is more appropriate for your workflow.
Does a small p-value automatically mean the population is not in equilibrium?
No. It means the observed deviation is unlikely under the selected model. Interpretation still depends on sample quality, population structure, genotyping quality, and whether the assumptions are reasonable for your dataset.
How is this different from the Mendelian chi-square page?
Hardy-Weinberg uses sample-derived allele frequencies to build expected genotype counts for a population. Mendelian chi-square starts from a fixed inheritance ratio such as 3:1 or 9:3:3:1 for offspring counts from a planned cross.
Are calculations from this tool sent externally?
No. Calculations stay in your browser unless you deliberately share a URL.
Related tools
- Punnett square generatorStart here if you still need to build the expected genotype or phenotype ratio from a specific cross.
- Mendelian ratio chi-square test calculatorUse this when expected counts come from an inheritance ratio such as 3:1 or 9:3:3:1 instead of from sample-derived p and q.
- Genetic drift simulator (Wright-Fisher)Open this next when you want to model how finite population size, selection, or migration can move allele frequencies over time.