Most people get stuck on statistics for one simple reason. The formulas look different for every test, so it feels like you must memorize a dozen unrelated things. You don’t. Once you see the one idea behind them, how to compute a test statistic gets much easier.
I’m writing this from research and from the mix-ups I see most often, not from a lab or classroom story. I’ll show you the shared pattern, walk through four worked examples with real numbers, and point out the traps. I’ll also flag the values you should double-check, like critical values from tables. Let’s start with the big idea.
What a Test Statistic Really Tells You
A test statistic is a single number. It tells you how far your sample result sits from what you’d expect if nothing interesting were going on. Bigger numbers (in absolute value) mean your data look less like the “nothing is going on” story.
That’s all it is. The rest is just details about which formula to use.
The One Idea Behind How to Compute a Test Statistic
Many common test statistics follow the same pattern. You take what you observed, subtract what you’d expect under the null hypothesis, and divide by a measure of noise. In plain form, it looks like this:
test statistic = (observed − expected) / standard error
The z-test and t-test fit this pattern exactly. The chi-square and F statistics look different, but they also compare what you saw to what you’d expect. I’d say this is the single most useful thing to remember.
Signal vs. Noise
Think of the top of the fraction as the signal. It’s the difference you found. The bottom is the noise. It shows how much that difference could bounce around by chance.
If the signal is large compared to the noise, the test statistic is large. That makes chance a weaker explanation. If the signal is small compared to the noise, the statistic is near zero, and your result is easy to explain by chance.
| Piece | What It Represents |
|---|---|
| Observed value | What your sample showed |
| Expected value | What the null hypothesis predicts |
| Standard error | How much sample results wobble by chance |
Before You Compute a Test Statistic: Get the Setup Right
Most mistakes happen before any math starts. If you pick the wrong test or state the wrong hypotheses, a perfect calculation still gives a useless answer.
So take a few minutes to set things up. It saves a lot of pain later.
Write Down Your Hypotheses
The null hypothesis, written H0, says nothing special is happening. For example, “the true mean equals 50.” The alternative, written H1 or Ha, says something is different.
Your alternative can be two-sided (not equal to), or one-sided (greater than or less than). Decide this before you look at the data. Switching afterward is a form of cheating, even if it isn’t intentional.
Choose Your Significance Level
The significance level, alpha, is the risk you accept of rejecting a true null hypothesis. Many fields use 0.05, but that’s a convention, not a law. Some fields use 0.01 or other values.
Pick alpha before you run the test. It’s a decision about how much evidence you want, so make it up front.
Pick the Right Test
The right test depends on your data type, your question, and what you know about the population. Here’s a quick guide.
| Situation | Typical Test |
|---|---|
| One mean, population standard deviation known | One-sample z-test |
| One mean, standard deviation estimated from sample | One-sample t-test |
| Compare two group means | Two-sample t-test |
| One proportion vs. a target | z-test for a proportion |
| Observed counts vs. expected counts | Chi-square test |
| Compare means of 3+ groups | ANOVA (F test) |
This table is a simplification. Assumptions matter, and I’ll mention them below.
Symbols to Know Before Learning How to Compute a Test Statistic
Half the confusion comes from symbols. Statistics books use many letters, and the same letter can mean different things in different places. Here are the ones you’ll see most.
Keep this handy as you read the examples.
| Symbol | Meaning |
|---|---|
| x̄ | Sample mean |
| μ₀ | Mean claimed by the null hypothesis |
| σ | Population standard deviation |
| s | Sample standard deviation |
| n | Sample size |
| p̂ | Sample proportion |
Some books use slightly different notation. If your textbook differs, follow your textbook.
How to Compute a Test Statistic Step by Step
Here is the general process. It works for most tests, with small changes in the middle.
I’d print this list and keep it next to you the first few times.
The Six-Step Process
First, state H0 and H1. Second, choose alpha. Third, choose the test and check its assumptions. Fourth, collect your summary numbers, like the mean, standard deviation, and sample size.
Fifth, compute the standard error and then the test statistic. Sixth, compare your result to a critical value, or find the p-value, and state your conclusion in plain words.
Where the Formulas Live
Here are the formulas for the most common tests. I’ve written them in plain text so they’re easy to copy.
| Test | Formula |
|---|---|
| One-sample z | z = (x̄ − μ₀) / (σ / √n) |
| One-sample t | t = (x̄ − μ₀) / (s / √n) |
| Two-sample t (Welch) | t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂) |
| z for a proportion | z = (p̂ − p₀) / √(p₀(1 − p₀)/n) |
| Chi-square | χ² = Σ (O − E)² / E |
For ANOVA, the F statistic is the variation between groups divided by the variation within groups. I’ll touch on that near the end.
Worked Example 1: How to Compute a Test Statistic for a z-Test
Let’s make this real. This first example shows how to compute a test statistic when σ is known. A z-test applies when you know the population standard deviation. That’s rare in practice, but it’s a good way to learn the pattern.
Suppose a factory says its bolts have a mean length of 50 mm. You test a sample to check.
The Numbers
You measure 64 bolts. The sample mean is 52 mm. The population standard deviation is known to be 8 mm. Your null hypothesis says the true mean is 50.
So x̄ = 52, μ₀ = 50, σ = 8, and n = 64.
The Calculation
First, find the standard error. It’s σ divided by the square root of n. The square root of 64 is 8, so the standard error is 8 / 8 = 1.
Next, compute z. That’s (52 − 50) / 1 = 2. Your test statistic is z = 2.
What It Means
For a two-sided test at alpha 0.05, the critical z-values are about ±1.96. That’s a standard value, but please verify it against a z-table. Since 2 is larger than 1.96, you’d reject the null at the 5% level.
In plain words, a sample mean this far from 50 would be fairly unusual if the true mean really were 50.
Worked Example 2: How to Compute a Test Statistic for a t-Test
Real life usually means you don’t know σ. You estimate it from the sample using s. When you do that, you use a t-test instead of a z-test.
The structure is the same. Only the standard deviation, and the reference distribution, change.
The Numbers
Say a company claims a battery lasts 5.0 hours on average. You test 36 batteries. The sample mean is 5.4 hours, and the sample standard deviation is 0.9 hours.
So x̄ = 5.4, μ₀ = 5.0, s = 0.9, and n = 36.
The Calculation
The standard error is s / √n. The square root of 36 is 6, so the standard error is 0.9 / 6 = 0.15.
Then t = (5.4 − 5.0) / 0.15 = 0.4 / 0.15, which is about 2.67. The degrees of freedom are n − 1, or 35.
What It Means
For a two-sided test at alpha 0.05 with 35 degrees of freedom, the critical value is roughly 2.03. I’m recalling this from a standard t-table, so please confirm it with a table or software. Since 2.67 is larger than 2.03, you’d reject the null.
So the batteries likely differ from the claimed 5.0 hours. Notice how similar this is to the z-test. The recipe barely changed.
Worked Example 3: How to Compute a Test Statistic for Two Groups
Often you want to compare two groups, not one group against a claim. The two-sample t-test handles that. I’ll use the Welch version, which doesn’t assume the two groups have equal variances.
The top of the fraction is now the difference between the two sample means.
The Numbers
Group A has a mean of 78, a standard deviation of 10, and 25 people. Group B has a mean of 72, a standard deviation of 12, and 30 people.
Your null hypothesis says the two true means are equal.
The Calculation
First, find the standard error of the difference. Square each standard deviation and divide by its sample size. For group A, that’s 100 / 25 = 4. For group B, that’s 144 / 30 = 4.8.
Add them to get 8.8, then take the square root to get about 2.97. The top of the fraction is 78 − 72 = 6. So t = 6 / 2.97, or about 2.02.
What It Means
The Welch degrees of freedom work out to about 53 for these numbers. At alpha 0.05, the two-sided critical value is a little above 2.0. Your result is right on the edge.
The p-value is likely close to 0.05, perhaps just under it. I’d use software to get the exact figure rather than trust my rough estimate. This is a good example of why results near the line deserve a careful look, not a quick yes or no.
Worked Example 4: How to Compute a Test Statistic With Chi-Square
The chi-square test is different. It compares counts, not means. You see how far observed counts are from expected counts.
Let’s test whether a die looks fair.
The Numbers
You roll a die 60 times. If it’s fair, you’d expect each face to show up 10 times. You observe these counts for faces 1 through 6: 8, 12, 9, 11, 14, and 6.
Your null hypothesis says the die is fair.
The Calculation
For each face, compute (observed − expected)² / expected. Face 1: (8 − 10)² / 10 = 0.4. Face 2: (12 − 10)² / 10 = 0.4. Face 3: (9 − 10)² / 10 = 0.1.
Face 4: (11 − 10)² / 10 = 0.1. Face 5: (14 − 10)² / 10 = 1.6. Face 6: (6 − 10)² / 10 = 1.6. Add them up, and χ² = 4.2.
What It Means
The degrees of freedom are the number of categories minus one, so 5. At alpha 0.05, the critical value is about 11.07. Please verify that with a chi-square table. Since 4.2 is less than 11.07, you don’t reject the null.
That doesn’t prove the die is fair. It just means these results don’t give strong evidence that it’s unfair. That’s an important difference.
A Quick Look at Proportions and ANOVA
Two more tests come up a lot. Both use the same signal-and-noise thinking.
I’ll keep this short, since the earlier examples cover the core skills.
z-Test for a Proportion
Say you want to test whether a coin lands heads half the time. In 100 flips, you get 56 heads. So p̂ = 0.56 and p₀ = 0.50.
The standard error under the null is √(0.5 × 0.5 / 100) = 0.05. Then z = (0.56 − 0.50) / 0.05 = 1.2. That’s smaller than 1.96, so you wouldn’t reject the null here.
The F Statistic in ANOVA
ANOVA compares the means of three or more groups. The F statistic is a ratio. It compares how much the group means differ from each other to how much the data vary inside each group.
A large F suggests the group means differ more than chance would predict. Doing it by hand takes several steps, so most people use software for ANOVA.
How to Read Your Test Statistic
Computing the number is only half the job. You also need to interpret it. There are two common ways to do that.
Both lead to the same decision when done correctly.
Critical Value Method
Look up a critical value for your test, alpha, and degrees of freedom. If your test statistic is beyond that cutoff, you reject the null hypothesis.
For a two-sided test, “beyond” means either direction. For a one-sided test, it means only in the direction of your alternative.
| Alternative Hypothesis | You Reject When |
|---|---|
| Not equal (two-sided) | Statistic is far in either tail |
| Greater than | Statistic is far in the right tail |
| Less than | Statistic is far in the left tail |
P-Value Method
The p-value is the probability of getting a result at least as extreme as yours if the null hypothesis were true. If the p-value is below alpha, you reject the null.
A p-value is not the probability that the null hypothesis is true. That’s one of the most common misunderstandings in all of statistics. It’s worth saying out loud, because many textbooks and news stories get it wrong.
A Rough Feel for Size
As a rough guide for z and t statistics, values near zero suggest little evidence against the null. Values beyond about 2 in absolute value often start to look meaningful at the 5% level. This is a rule of thumb, not a rule.
Sample size, test type, and degrees of freedom all change the exact cutoff. Use it only to build intuition.
Common Mistakes When You Compute a Test Statistic
Even careful people slip. These are the errors I’d watch for the most. They’re all easy to fix once you know about them.
Many come from rushing the setup or skipping the assumptions.
Using the Wrong Test
A classic error is using a z-test when σ is unknown. Another is using a two-sample test on data that are paired, like before-and-after measurements on the same people.
Paired data need a paired t-test. It works on the differences within each pair, not on two separate groups.
Mixing Up Standard Deviation and Standard Error
The standard deviation describes how spread out your data are. The standard error describes how spread out your sample mean would be. You divide by √n to get from one to the other.
Forgetting to divide by √n is a common slip. It makes your test statistic far too small.
Ignoring Assumptions
Most tests have assumptions. The t-test assumes roughly normal data or a large enough sample, independent observations, and no major outliers. Chi-square tests usually want expected counts that aren’t tiny. A common rule of thumb says each expected count should be at least 5, but check your textbook.
I’d also be careful with the old “n ≥ 30 is always fine” rule. It’s a rough guide, and it fails with very skewed data.
Stopping at “Significant”
A significant result doesn’t automatically mean an important one. With a large sample, tiny differences can be significant. Always look at the size of the effect, too.
| Mistake | Better Approach |
|---|---|
| z-test with unknown σ | Use a t-test |
| Treating paired data as two groups | Use a paired t-test |
| Forgetting to divide by √n | Compute the standard error first |
| Reading p as “chance the null is true” | Learn what p actually measures |
Using Software to Check How to Compute a Test Statistic by Hand
Doing it by hand teaches you the logic. But for real projects, software is faster and less error-prone. I’d suggest doing both. Calculate by hand once, then confirm with software.
Most programs give you the test statistic, the degrees of freedom, and the p-value together.
A Quick Python Example
If you use Python with the SciPy library, a one-sample t-test looks like this:
python
from scipy import stats
result = stats.ttest_1samp(data, popmean=5.0)
print(result.statistic, result.pvalue)Here, data is your list of measurements. The function returns the t statistic and the p-value. Check the SciPy documentation for the latest details, since function options can change between versions.
Spreadsheets and Other Tools
Many spreadsheet programs have add-ons or built-in tools for t-tests, and some report the test statistic directly. I’m not certain of the exact menu names in every version, so check your tool’s help pages. R, SPSS, and Stata also report test statistics for most standard tests.
Frequently Asked Questions
These are short answers to common questions. They’re general information, so check your textbook or instructor for details that apply to your course.
What is a test statistic in simple terms?
It’s a number that measures how far your sample result is from what the null hypothesis predicts, scaled by the noise in the data. Larger absolute values suggest stronger evidence against the null.
How to compute a test statistic for a t-test?
Subtract the hypothesized mean from your sample mean. Then divide by the sample standard deviation over the square root of n. That is t = (x̄ − μ₀) / (s / √n).
What is the difference between a z-score and a test statistic?
A z-score is a standardized value. A z test statistic is a z-score applied to a sample statistic, like the sample mean, compared to the null value. So a z test statistic is one kind of z-score.
Can a test statistic be negative?
Yes. For z and t statistics, a negative value means your sample result is below the null value. Chi-square and F statistics can’t be negative, because they involve squared terms or ratios of variances.
Do I need the test statistic if I have the p-value?
Software gives you both, and they carry the same decision. Reporting the statistic along with degrees of freedom is good practice, since it lets others check your work.
Final Thoughts
The biggest lesson is that how to compute a test statistic comes down to one pattern. Take what you observed, subtract what the null predicts, and divide by the noise. Once you see that, the z, t, and chi-square formulas stop looking like separate puzzles.
My honest opinion is that setup matters more than arithmetic. Pick the right test, state your hypotheses first, and check your assumptions. Do a few examples by hand, then lean on software. If you’re unsure about a critical value or an assumption, look it up in your textbook or a trusted reference before you rely on it.

Ehatasamul Alom is a dedicated health-tech enthusiast and the co-founder of BMRCalculator. With a passion for metabolic science, he focuses on providing accurate health data for the UK community. Ehatasamul ensures that every tool and guide aligns with NHS standards and public health research. His mission is to simplify complex biological data, helping British residents make informed decisions about their fitness, calorie needs, and long-term wellness. When not analyzing health trends, he explores the latest innovations in wearable fitness technology.



