Chi-Square Goodness-of-Fit Test Calculator
The chi-square goodness-of-fit test (Pearson 1900) is the workhorse for asking whether a categorical distribution matches an a-priori theoretical one. χ² = Σ (O_i − E_i)² / E_i with degrees of freedom df = categories − 1 − parameters-estimated. The tool supports uniform, ratio / probability and explicit expected-count modes, and auto-flags Cochran's low-expected-count caveat.
Presets
Check inputs: observed counts must be ≥ 2 non-negative numbers; expected (if given) must match observed in length.
Results
χ² statistic
—
Degrees of freedom
—
p-value
—
Conclusion (upper-tail test)
—
| # | Observed O | Expected E | (O−E)² / E |
|---|
Pearson χ² upper-tail test; p-value via P(χ²_df > statistic). Approximation improves with larger expected counts (Cochran: each cell ≥ 5).
Formula
χ² = Σ_i (O_i − E_i)² / E_i; df = k − 1 − (params estimated); p-value = P(χ²_df > observed χ²) via the regularized incomplete gamma function.
- · Null hypothesis H₀: observed distribution matches the theoretical one. Reject H₀ when p < α (significant deviation); fail to reject when p ≥ α (data is consistent with theory).
- · Cochran (1954) rule of thumb: each expected count E_i should be ≥ 5 for the χ² approximation to be reliable. If E_i < 5: (1) merge sparse cells; (2) use Fisher's exact test (small 2×2 tables); (3) bootstrap or permutation sampling.
- · Df adjustments: pure goodness-of-fit k = 0; fitting a Poisson rate k = 1; fitting Normal(μ, σ) k = 2. More parameters estimated → fewer df → same χ² maps to a larger p (harder to reject H₀).
- · Mendel's (1866) 9:3:3:1 pea ratio is the textbook example: observed (315, 108, 101, 32) on n = 556 gives χ² ≈ 0.470, df = 3, p ≈ 0.925 — strong support for the inheritance ratio. Fisher (1936) famously questioned whether Mendel's data was "too good" (p-values clustering above 0.95 is improbable), but that critique is about data-collection, not about the χ² procedure.
- · Unlike a z / t test, χ² handles *categorical counts* not continuous measurements. To compare two proportions (e.g. A: 52 % click, B: 48 %), valid options are: (1) χ² 2×2 (this tool); (2) two-proportion z test; (3) Fisher exact test. The three agree in large samples; Fisher is the right call when expected counts are small.
- · The p-value is computed via the regularized upper incomplete gamma function Q(df/2, χ²/2) using the standard series + continued-fraction algorithm (Numerical Recipes 3rd ed., §6.2), accurate to better than 1e-12 across the usable range.
- · References: Pearson (1900), Philosophical Magazine 50; Cochran (1954), Biometrics 10(4); Mendel (1866), Versuche über Pflanzenhybriden; Numerical Recipes 3rd ed., §6.2.
Frequently asked
Is the chi-square test one-tailed or two-tailed?
The χ² goodness-of-fit test is always *one-sided (upper-tail)*: p-value = P(χ²_df > observed). The χ² statistic is non-negative by construction; a larger value means a bigger gap between observed and expected. Under H₀ the statistic concentrates near df, so "too large" is what triggers rejection. The "two-tailed" framing does not apply to goodness-of-fit because the deviation has no direction. (A different test, χ² for variance with H₀: σ² = σ₀², is two-tailed and needs both tails computed separately — but that is a separate procedure.) This tool implements the upper-tail goodness-of-fit version by default.
Is the E_i < 5 rule really that strict — my sample is just small?
Cochran's (1954) rule is not a hard prohibition — it is a calibration warning. Empirical studies (Hutchinson 1979, Slakter 1965) show: (1) all E_i ≥ 5 → χ² approximation matches the exact sampling distribution closely, p-values are nearly unbiased; (2) some E_i in 1–5 → p-value bias is modest, acceptable with ~10 % extra uncertainty; (3) multiple E_i < 1 → bias is substantial, p-values can be off by factors of 2–3. Practical responses: (1) merge sparse cells until each ≥ 5; (2) use Fisher's exact test (especially for 2×2 tables) — R's chisq.test() defaults to Monte-Carlo simulation with a warning when this fires; (3) Yates' continuity correction (2×2, small expectations) — but it tends to be overly conservative. For everyday A/B testing with n > 500, the rule is usually satisfied automatically and no action is needed.
When to pick the χ² test vs the G-test / likelihood-ratio test?
In large samples the two give nearly identical p-values, but G = 2 · Σ O_i · ln(O_i / E_i) has a cleaner likelihood-ratio derivation and is preferred in modern statistics texts (Sokal & Rohlf "Biometry", 4th ed., leans towards G). Practical trade-offs: (1) χ² is more widely accepted — CFA, medical journals and SPSS default to it; (2) G is mathematically consistent with the likelihood / information-theoretic framework (AIC, BIC, mutual information) and shows up everywhere in machine learning; (3) both degrade with low expected counts, but G admits Williams' correction for small samples; (4) G needs the 0·ln(0) = 0 convention for empty cells, χ² is simpler. Rule of thumb: report χ² for peer communication; add G for rigorous academic work; prefer G in ML / information-theory settings (it is the same shape as KL divergence).
Related tools
Percentage Calculator
Percent of, percent change, and percent add/subtract in one.
GCD & LCM Calculator
Enter 2–6 positive integers to get the greatest common divisor (HCF / GCD) and least common multiple (LCM), with the Euclidean step chain shown.
Average Calculator (Mean / Median / Mode)
Enter a list of numbers to get the mean, median, mode, range plus standard deviation, variance and total.
Quadratic Equation Solver
Enter the coefficients of ax² + bx + c = 0 to find the real or complex roots, discriminant and vertex.
Password Strength (Entropy) Calculator
Estimate a password's bit entropy, brute-force time and strength tier. All computation happens in your browser.
Scientific Notation Converter
Convert between standard decimal numbers and scientific notation, with significant figures and order of magnitude.
Permutations & Combinations (nPr / nCr) Calculator
Compute permutations P(n,r), combinations C(n,r) and factorial n! — useful for probability problems, lottery odds and combinatorics homework.
Standard Deviation Calculator
Paste a list of numbers to compute mean, median, sample and population variance and standard deviation — with the working shown.
Triangle Calculator (SSS / SAS / ASA)
Solve a triangle from 3 sides, 2 sides + 1 angle, or 2 angles + 1 side — area, perimeter and remaining parts via the law of sines / cosines.
Pythagorean Theorem Calculator
Given any two sides of a right triangle (two legs, or one leg plus the hypotenuse), instantly find the third side, area, perimeter and the two non-right angles.
Circle Calculator (radius / diameter / circumference / area)
Enter any one of radius, diameter, circumference or area to get the other three — useful for design, engineering and DIY.
Roman Numeral Converter
Two-way conversion between Arabic numbers (1–3999) and Roman numerals (I, V, X, L, C, D, M) — handy for typesetting, chapter titles and homework.
Slope & Line Equation Calculator (y = mx + b from Two Points)
Enter two points (x₁, y₁) and (x₂, y₂) to instantly get the slope, y-intercept, line equation y = mx + b, distance, and midpoint — a classroom staple for algebra and coordinate geometry.
Birthday Paradox Calculator
Enter group size n to see the probability that at least two people share a birthday — the classic birthday problem.
Logarithm Calculator (log / ln / log₂ / any base)
Compute logₐ(x) for any base — natural log (ln), common log (log₁₀), binary log (log₂) and a custom base, with the change-of-base steps shown.
Z-Score (Standard Score) Calculator
Enter a value, the mean and the standard deviation to compute the z-score and the corresponding normal-distribution percentile and probabilities.
Screen Pixel Density (PPI) Calculator
Enter the screen resolution and diagonal size to get pixel density (PPI), real width/height, dot pitch and total pixel count.
Hong Kong Mark Six Odds Calculator
Enter the number of tickets / selections and see the actual probability of hitting first, second … prizes in a Mark Six (6-of-49) draw.
Decimal to Fraction Converter
Convert any decimal (including repeating decimals) to a simplified fraction and a mixed number.
Sphere Volume & Surface Area Calculator
Give a sphere any one of radius, diameter, surface area or volume and instantly get the other three — plus the great-circle circumference and area.
Cylinder Volume & Surface Area Calculator
Enter the radius and height of a cylinder to get volume (π r²h), lateral surface, base area and total surface area.
Permutations (nPr) Calculator
Compute nPr — the number of ordered arrangements of r items chosen from n — alongside n!, r! and the related combination nCr.
Prime Factorization Calculator
Factor any integer from 2 up to 10¹² into primes, see the canonical exponent form, count and list all divisors.
Geometric Mean Calculator
Compute the n-th root of the product of n positive numbers — the right average for growth rates, returns and ratios — alongside the arithmetic mean for comparison.
Fibonacci Sequence Calculator
Enter any integer n from 0 to 1500 to instantly compute F(n) and F(n−1) with BigInt precision, the consecutive-term ratio (converging to the golden ratio φ) and the first 30 terms of the sequence.
Dice Roll Probability Calculator
Pick the number of dice, sides (d4 / d6 / d8 / d10 / d12 / d20) and a target sum to compute the probability of rolling exactly that total, at least, or at most.
Arithmetic Series Calculator
Enter first term a, common difference d and number of terms n to compute the nth term aₙ and the partial sum Sₙ = n/2·(2a + (n − 1)d).
Survey Sample Size Calculator
Enter confidence level, margin of error, expected proportion (and optional population size) to compute the survey sample size you need.
Geometric Series Sum Calculator
Enter the first term a, common ratio r and number of terms n to find the sum of the first n terms of a geometric series — plus the infinite-series sum when |r| < 1.
Cone Volume & Surface Area Calculator
Enter base radius and height to get the cone volume, slant height, lateral, base and total surface area.
Music Note Frequency Calculator
Pick a note (C, C♯, D, …), octave and tuning reference A4 (440 Hz by default) and the tool returns the frequency in Hz, the wavelength in air and the MIDI note number via f = A4 × 2^((n − 69)/12).
Linear Interpolation Calculator (Lerp)
Enter two known points (x₁, y₁) and (x₂, y₂) and a target x to instantly read off y via y = y₁ + (x − x₁)(y₂ − y₁)/(x₂ − x₁) — the tool flags whether your x sits inside the two points (interpolation) or outside (extrapolation).
Trapezoid Area Calculator
Enter the two parallel sides and height of a trapezoid to get its area, midsegment length and perimeter when the legs are known.
Binomial Probability Calculator
Enter the number of trials n, the per-trial success probability p and a target number of successes k to get P(X = k), P(X ≤ k), P(X ≥ k) along with the distribution mean and standard deviation.
Pearson Correlation Coefficient Calculator
Paste two parallel data series (X and Y) and get the Pearson correlation coefficient r, r², the best-fit line slope and intercept, and the sample means and standard deviations.
Confidence Interval for the Mean Calculator
Enter the sample mean, sample standard deviation, sample size and confidence level to compute a confidence interval for the population mean using the t (or z) distribution, with margin of error and standard error.
Cohen's d Effect Size Calculator
Enter the means, standard deviations and sample sizes of two groups to compute Cohen's d and Hedges' g effect sizes, classified per Cohen 1988 as trivial / small / medium / large.
Modulo (Remainder) Calculator
Enter dividend a and divisor n to compute the quotient and remainder a mod n. The truncated (C / JavaScript %), floored (Python / mathematical) and Euclidean conventions are shown side by side so the negative-input differences are obvious.
chmod Permission Converter (Octal ↔ rwx)
Toggle read/write/execute for user, group and other to instantly get both octal (e.g. 755) and symbolic (e.g. rwxr-xr-x) notations.
Vector Magnitude & Direction Calculator (2D / 3D)
Enter 2D or 3D vector components (x, y, z) to compute the magnitude, unit vector and direction angles.
Percent Error Calculator (Percent Error & Percent Difference)
Enter experimental and theoretical (accepted) values to get absolute percent error, signed relative error, and absolute error. Switch to percent-difference mode to compare two measurements where neither is the accepted value.
Poisson Distribution Probability Calculator
Enter the mean event rate λ and an event count k to get P(X = k), P(X ≤ k), P(X ≥ k), the mean, variance and standard deviation — useful for queueing, call-centre staffing and rare-event modelling.
Bayes’ Theorem Probability Calculator
Enter the prior P(A), the sensitivity P(B|A) and the false-positive rate P(B|¬A); the tool applies Bayes’ theorem to give the posterior P(A|B) — handy for medical tests, spam filters and any classification decision.
Arc Length & Sector Area Calculator
Enter a circle’s radius and central angle (degrees or radians) to compute the arc length s = r·θ, sector area A = ½·r²·θ and chord length — useful for geometry, machining and architectural layout.
Matrix Determinant Calculator (2×2 and 3×3)
Enter the entries of a 2×2 or 3×3 matrix and instantly get the determinant det(A) via ad − bc or cofactor expansion along the first row, with an invertibility check and the step-by-step 2×2 minors shown for linear-algebra study.
Vector Dot Product Calculator (2D / 3D)
Enter two 2D or 3D vectors and instantly compute the dot product, included angle, scalar projection and vector projection — with hints for orthogonal, parallel and anti-parallel cases.
Cosine Similarity Calculator
Enter two numeric vectors of any dimension and compute cos θ = (a·b) / (|a|·|b|), plus the angular distance — the staple similarity metric in NLP, recommender systems and document-similarity scoring.
Percent Difference Calculator (Symmetric)
Enter two values and compute the symmetric percent difference |a − b| / ((|a| + |b|) / 2) alongside the directional percent change (b − a)/a — a common source of confusion in lab reports and news headlines.
Vector Cross Product Calculator (3D)
Enter two 3D vectors a and b, compute the cross product a × b together with its magnitude (the area of the parallelogram they span) and sin θ — the workhorse of physics torque, computational geometry and 3D graphics.
Distance Between Two Points Calculator (2D / 3D)
Enter two points in the plane or in 3D space and the tool returns the straight-line Euclidean distance √Σ(Δᵢ)², each axis delta and the midpoint — handy for geometry homework, CAD measurements and planar GIS work.
Coefficient of Variation Calculator (CV)
Enter a dataset and the tool returns the coefficient of variation CV = σ / μ × 100% (standard deviation divided by mean) — the standard yardstick for comparing dispersion across datasets with different units or magnitudes (lab repeatability, portfolio risk).
Median, Quartiles & IQR Calculator
Enter a dataset and the tool sorts it and returns the median, first and third quartiles, the inter-quartile range (IQR) and Tukey 1.5×IQR outlier fences — the five-number summary behind every box plot.
Harmonic Mean Calculator
Enter a set of positive numbers and compute the harmonic mean HM = n / Σ(1/xᵢ) alongside the arithmetic and geometric means — the right average when the data behaves like rates or denominators (speeds, P/E ratios, flow rates).
Shannon Entropy Calculator
Enter a list of class probabilities or frequencies and compute Shannon entropy H = −Σ pᵢ log₂ pᵢ (bits) alongside the maximum entropy and the normalised entropy — the foundation of information theory, decision-tree splits and password analysis.
Regular Polygon Calculator (Area, Angles, Radii)
Enter the side count n and side length s of a regular polygon and the tool returns the interior and exterior angles, the apothem and circumradius, the area and the perimeter in one shot — works for triangles, squares, pentagons, hexagons and beyond.
Catalan Number Calculator (Cₙ)
Enter n and the tool returns the n-th Catalan number Cₙ = (2n)! / ((n+1)! · n!) — the textbook count for balanced parentheses, binary tree shapes, Dyck paths and many other combinatorics problems.
RMSE / MAE Forecast Error Calculator
Enter a column of actual values and a column of predicted values; the tool computes MAE, MSE, RMSE, R² and MAPE side-by-side — the staple set of regression-error metrics in machine learning, forecasting and lab-vs-model comparisons — and explains how each one weights outliers differently.
Linear System Solver — 2 Equations, 2 Unknowns
Enter the 6 coefficients of ax + by = e and cx + dy = f. The tool applies Cramer's rule to return x, y, the determinant D and the system's classification (unique solution / no solution / infinitely many), showing the working out so it doubles as a homework check.
At-Least-One Probability Calculator
Enter a per-trial probability p and a trial count n; the tool returns the probability of at least one success 1 − (1 − p)ⁿ, the expected count np, and the trials needed to reach a target probability — the maths behind raffles, gacha pulls, A/B tests and redundancy design.
Expected Value Calculator (E[X] = Σ p·x)
Enter outcome values x and matching probabilities p; the tool returns the expected value E[X] = Σ p·x, variance Var(X) and standard deviation σ — the foundational metric for casino games, insurance pricing, investment decisions and A/B-test analysis.
Margin of Error Calculator (Polls & Sampling)
Enter sample size n, sample proportion p (or sample standard deviation) and a confidence level (90 / 95 / 99 %); the tool computes the margin of error MOE = z·√(p(1−p)/n) and the matching confidence interval — the core statistic behind political polls, A/B tests and market research.