← Biology

genetics χ² test

Hardy-Weinberg equilibrium calculator

Enter observed AA/Aa/aa counts or allele frequencies to calculate p and q, expected genotype frequencies, χ², and p-value. Use it when your question is about population-level equilibrium, not a single-cross inheritance ratio.

All calculations are done within the browser and no data is sent.

Other languages 日本語 | English | 简体中文 | Español | Português (Brasil) | Bahasa Indonesia | Français | हिन्दी | العربية

Example (preset)

Once you select an example, the input will be filled in and the results will appear immediately.

Description

Inputs

Input mode

Observed genotype counts (AA/Aa/aa)

Degrees of freedom (df)
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

N (total number)
p(A)
q(a)
MAF (reference)
χ²
df
p-value
Judgment (for display)
Hobs (observation hetero)
Hexp (expected hetero)
F (reference)

*This is a statistical calculation tool and is not intended for medical judgment.

graph

Observation vs Expectation
residual

*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

  1. Enter AA/Aa/aa (you can also use the example).
  2. Select degrees of freedom (default is df=1) and significance level (for display).
  3. 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

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?

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.