t-Tests · General Linear Model
One-Sample t-Test
A one-sample t-test compares a sample's mean with a set value.
A one-sample t-test takes one continuous variable from one sample and tests whether its population mean differs from a specified value.
Do undergraduates sleep less than the recommended minimum of 7 hours a night? Forty students logged their sleep for a week, and each student's nightly average is one score.
- Tests
- Population mean
- Observations
- Independent
- Parametric
- Yes
- Headline Statistic
- t
- Effect Size
- Cohen's d
- Groups
- 1
The Basics
When to Use It
Use it when you have one group, one continuous outcome, and a specific value worth comparing the group's average against, chosen before you look at the data. For example:
- Do students sleep less than the recommended minimum of 7 hours?
- Does a clinic sample's mean T-score differ from the population norm of 50?
- Is mean reaction time on this task different from the 250 ms reported in earlier work?
The test starts from the null hypothesis, the claim of no difference: here, that the population mean equals the comparison value. It asks how strongly the data argue against it.
Vocabulary You Need
Definition Standard Deviation (s)
How spread out individual scores are around their mean. For roughly bell-shaped scores, about two-thirds fall within one standard deviation of the mean. Its square, s², is the variance: the average squared distance from the mean (dividing by n − 1). Glossary →
Definition Standard Error (SE)
How much a statistic, such as a mean, a proportion or a difference between two of them, would vary from one sample to the next. SD asks how much individuals vary; SE asks how sure we are about the estimate. It shrinks as the sample grows. Glossary →
Definition Degrees of Freedom (df)
How much independent information is left for estimating variability, after the quantities estimated from the same data are accounted for. Each estimated quantity uses one up: with a single mean, deviations from it always sum to zero, so once you know n − 1 of them the last is fixed; two group means use up two (N − 2), and a regression with k predictors and an intercept uses k + 1. Degrees of freedom pick which t, F or χ² distribution a result is judged against, and fewer of them mean heavier tails (more extreme values), so a result needs a bigger statistic to count as significant. Some tests, such as Welch's t or a sphericity-corrected F, use fractional values. In a table of counts, it's the number of cells free to vary once the row and column totals are fixed. Glossary →
Definition Q-Q Plot
A quantile-quantile plot. Sort the scores, and pair each with the value the named distribution (usually the normal) expects for a score in that position, then plot the pairs. If the data follow the distribution, the points lie close to a straight line. The shape of any bend is informative, but the picture depends on two conventions. R, Python and this site put the expected values across the bottom, while SPSS puts them up the side; and programs draw the reference line differently (through the quartiles, by least squares, or from the mean and SD). So rather than memorize bend shapes, compare the sorted scores with the expected values directly. Where the scores run further from the center than expected, that tail is longer than a normal curve's; where they fall short, it is shorter. Right skew shows as the highest scores running further out than expected and the lowest falling short. Both tails running further out means heavier tails than normal, and a few points far from the rest at either end are possible outliers. With small samples some wiggle is normal, so look for a clear, systematic bend. Glossary →
Assumptions and Inference
1. Independent Students (for the p-Value and Intervals) The people (or other units) in your study don't influence each other.
- What It Means
- Each person's data comes from a separate, unconnected source, so knowing one person's scores tells you nothing about anyone else's. In designs that measure people more than once, their own scores are meant to be related; it's different people who must be independent. Methods built for clustered data, such as multilevel models and GEE, also allow members of the same group to be related, as long as the analysis names the grouping; then it's the groups that must be independent.
- Applies To
- Observations
- How to Check
- By design, not by a test. Did each person contribute their own data, with no clusters such as roommates, couples, therapy groups or classrooms whose members influence each other? If there are clusters, does the analysis model every one of them?
- How Much It Matters
- A lot. Clustered scores (from people who resemble each other, such as classmates) make the standard error too small, so p comes out too small.
What to Do
- Alternative Test Multilevel Regression (HLM). A multilevel model, which accounts for the clustering.
- Design Change Collect one score per independent unit.
2. Normality (for the p-Value and Intervals) The p-value and intervals are exact when the scores come from a normal population. With moderate departures they are usually close, more so in bigger samples, but strong skew, extreme outliers or heavy tails can still throw them off with 40 people.
- What It Means
- The scores here are the 40 students' weekly averages, not their 280 separate nights; an average of seven nights is already less skewed than single nights. With normal scores, t follows the t distribution exactly. Otherwise the test leans on the sample mean being roughly normal across repeated samples, which arrives sooner for mild skew than for severe skew or heavy tails, so a sample-size rule of thumb is no guarantee. The interval for d leans on normality much harder than the interval for the mean, and a bigger sample doesn't fix it.
- Applies To
- Outcome
- How to Check
- Look at a histogram or Q–Q plot for strong skew or extreme outliers. Don't rely on a normality test: with small samples it misses real problems, and with large ones it flags trivial ones. The sleep scores pass: their Q–Q plot (in Vocabulary) is close to a straight line, and no score is more than 2.7 standard deviations from the mean.
- How Much It Matters
- For the mean, less as n grows, but not to nothing. In simulations with 40 people and strongly right-skewed scores (lognormal, skewness about 6), the 95% interval for the mean covered the true mean only 89% of the time; with moderate skew (about 1.8), 94%. The noncentral-t interval for d fared worse: 85% with moderate skew and 66% with strong skew. If the scores are clearly skewed, bootstrap the interval for d as well.
What to Do
- Robust Estimation Bootstrap a confidence interval for the mean.
- Alternative Test Wilcoxon Signed-Rank Test. It asks whether scores are centered on the comparison value, assuming they're roughly symmetric; it tests the median only under that symmetry. With skewed scores, a sign test compares the median with the value without that assumption.
- Transformation Log-transform right-skewed outcomes such as reaction times, and log the comparison value too. The test then compares the geometric mean (roughly the typical score), not the mean, with the value.
Limitations
This Is Not Your Test If…
- Your outcome isn't continuous (yes/no, categories, ranks) Categorical Data and Proportions →
- You're comparing two independent groups Independent-Samples t-Test →
- You measured the same people twice Paired-Samples t-Test →
- You're comparing three or more groups ANOVA Family →
- You're asking whether two variables are related Correlation and Association →
What It Doesn't Tell You
- Why. Nothing here explains why students sleep less; there's no manipulation and no comparison group.
- Whether it matters. Significance doesn't make half an hour of sleep important for health or grades.
- Who else. The result describes the population these 40 students represent, and only if they were sampled so as to represent it; independent scores aren't enough. It also holds only as well as self-reported sleep measures real sleep.
- How many students get enough sleep. The test is about the average. A mean of 6.50 hours doesn't say what share of students average under 7 hours; in our sample it was 26 of 40 (65%). To estimate that share, count the students below the line and give an interval for the proportion, as in the binomial test.
- That there's no difference, if p had been above .05. A non-significant result would have meant the data were inconclusive, not that students sleep 7 hours.
Common Mistakes
-
Don'tSwitch to a one-sided p because the result went the way you hoped.
InsteadUse a one-sided test only if you specified the direction before collecting data and have a defensible reason why an effect in the opposite direction wouldn't count toward your claim. Otherwise, use a two-sided test.
-
Don'tPick the comparison value after looking at the data.
InsteadFix it in advance from a guideline, norm or theory, and say where it came from.
-
Don'tCompare two groups by testing one group against the other group's mean.
InsteadUse an independent-samples t-test, which accounts for the uncertainty in both means.
-
Don'tRead a p-value as the chance that the null hypothesis is true.
InsteadRead it as: if the null were true, how often data at least this extreme would turn up.
Result Decoder
Significance and Effect Size Guidelines
Benchmarks Significance (p Value)
-
p < .001
Very strong evidence against the null hypothesis.
-
.001 ≤ p < .01
Strong evidence against the null hypothesis.
-
.01 ≤ p < .05
Statistically significant at α = .05. Moderate evidence against the null hypothesis.
-
.05 ≤ p < .10
Not significant. Weak evidence; sometimes called a “trend.” Treat it as inconclusive.
-
p ≥ .10
Not significant. Little evidence against the null, which is not the same as evidence of no effect.
These evidence labels are one common convention for describing p in graded language rather than as significant or not; the boundaries are rough guides, not rules, and other authors draw them differently. Muff et al. (2022) argue for this kind of language of evidence over a single cutoff. α is chosen before the analysis, and p never says how big or important an effect is.
Benchmarks Effect Size (Cohen's d)
-
|d| < 0.2
Below Small
Smaller than the conventional small benchmark. Whether an effect this size matters depends on the setting.
-
0.2 ≤ |d| < 0.5
Small
A relatively modest standardized difference
-
0.5 ≤ |d| < 0.8
Medium
A moderate standardized difference
-
|d| ≥ 0.8
Large
A relatively substantial standardized difference
The sign shows direction. Cohen (1988) named 0.2, 0.5 and 0.8 small, medium and large; the “below small” band under 0.2 is this site's label, not Cohen's. Benchmarks are conventions, not measures of practical or clinical importance.
How It's Reported
Equation Form
Mdiff = −0.50, 95% CI [−0.88, −0.12], d = −0.42, 95% CI [−0.74, −0.09], t(39) = −2.64, p = .012
Full Text (APA Style)
Students slept less than the recommended minimum of 7 hours a night (M = 6.50, SD = 1.20), a difference of −0.50 hours, 95% CI [−0.88, −0.12], d = −0.42, 95% CI [−0.74, −0.09]. A one-sample t-test showed the difference was statistically significant, t(39) = −2.64, p = .012.
- Name the comparison value, so readers know what “less” means.
- Give the size and interval before the significance test.
- Italicize statistical symbols (M, SD, d, t, p) and report exact p to three decimals.
Reading Each Piece
The equation form above, piece by piece, in this order: how big, how certain, then how surprising.
| Mdiff = −0.50 | Students slept half an hour less than the 7 hours we compared against. |
| d = −0.42 | The difference is 0.42 standard deviations. Negative means below 7. That's small by the benchmarks above; whether half an hour of sleep matters is a judgment about sleep, not statistics. Benchmarks ↑ |
| 95% CI [−0.88, −0.12] | The true difference is plausibly anywhere from about 7 to 53 minutes less. The whole range is below zero; a 95% CI that leaves out zero goes with a two-sided p below .05. |
| 95% CI [−0.74, −0.09] | The true difference is plausibly anywhere from about a tenth to three quarters of a standard deviation below 7: from below small to medium by the benchmarks above. Software finds it from the noncentral t distribution; SPSS prints it in the effect-size table. It relies on normal scores more than the interval for the mean does (see Assumptions and Inference). |
| t(39) = −2.64 | The difference is 2.64 standard errors below zero. The 39 is the degrees of freedom: n − 1. |
| p = .012 | If students really averaged 7 hours, a sample mean at least 2.64 standard errors from 7 (each sample judged by its own SD), in either direction, would turn up about 1.2% of the time. That's below .05, so the result is statistically significant. Benchmarks ↑ |
Calculations
The Running Example
The sleep study: 40 undergraduates, one nightly average each, compared against the recommended minimum of 7 hours.
- Null Hypothesis:
- \mu = 7
- Alternative (Two-Sided):
- \mu \neq 7
The null hypothesis is the claim of no difference that the test looks for evidence against; the alternative is any difference. \mu (“mu”) is the population mean, the average nightly sleep of all undergraduates, which the sample's 6.50 estimates. The question points one way (less sleep), but we test two-sided, the usual default, so a result in the unexpected direction would count too; a one-sided test needs a direction specified before collecting data and a defensible reason why an effect in the opposite direction wouldn't count toward the claim.
What Your Data Should Look Like
One row per person and one numeric column. The comparison value comes from outside the data: a guideline, a norm or a theory.
| participant | hours_slept |
|---|---|
| 1 | 9.7 |
| 2 | 6.8 |
| 3 | 5.5 |
| 4 | 7.1 |
| 5 | 7.0 |
| 6 | 4.3 |
| … 34 more rows | |
Napkin Math
The whole test, one idea at a time. Under each heading, a line says why the step matters, and the green note reads the equation in plain English with the sleep study's numbers. Collapse all to read just the headings: they tell the whole story on their own.
-
1. Find the Difference between What We Observed and What We Expected
Everything starts with the gap between what the sample shows and the value we're testing against. A negative gap means the sample came in below it.
\bar{x} - \mu_0 =6.50 - 7= −0.50 hours
\bar{x} is our students' average, 6.50 hours. \mu_0 is the 7 hours we're testing against. 6.50 − 7 = −0.50 hours.
-
2. Figure Out How Much People's Scores Naturally Vary
Before we can judge whether a gap is big, we need to know how much scores normally bounce around.
s = \sqrt{\dfrac{\sum (x_i - \bar{x})^2}{n - 1}}= 1.20 hours
x_i is each student's score and \sum means “add them all up.” So find each student's distance from 6.50, square it, add up all 40, divide by n - 1 = 39, and take the square root. That's 1.20 hours.
-
3. Figure Out How Precisely Our Sample Estimates the Population Average
An average of many people is steadier than any one person. The standard error measures how much a sample average would wobble from sample to sample.
SE = \dfrac{s}{\sqrt{n}} =\dfrac{1.20}{\sqrt{40}}= 0.190
s is that 1.20-hour spread and n is our 40 students. 1.20 ÷ √40 (about 6.32) = 0.19 hours, roughly 11 minutes.
-
4. Compare the Difference with That Uncertainty
A gap only means something relative to that wobble. t says how many standard errors the gap is.
t = \dfrac{\bar{x} - \mu_0}{SE} =\dfrac{-0.50}{0.1897}= −2.64
Our −0.50-hour gap divided by the 0.1897-hour SE puts the gap 2.64 standard errors below 7.
-
5. Account for How Much Information We Had
Estimating the mean uses up one piece of information. If there were no real difference, t would still vary from sample to sample, following a t distribution: a bell curve centered on 0 with heavier tails (more extreme values) than the normal curve, because s is itself an estimate. The fewer the df, the heavier the tails, so df tells us which t distribution to judge t against.
df = n - 1 =40 - 1= 39
n is our 40 students. 40 − 1 = 39.
-
6. Measure How Big the Difference Actually Is
t grows with sample size; d doesn't. Dividing by the spread between people instead of the standard error gives a size you can compare across studies.
d = \dfrac{\bar{x} - \mu_0}{s} =\dfrac{-0.50}{1.20}= −0.42
\text{CI}_{d} = [−0.74, −0.09]
The same −0.50-hour gap, divided by the 1.20-hour spread s instead, is 0.42 of a standard deviation.
-
7. Give a Range of Plausible Values for the True Difference
Instead of a single best guess, give the range of true differences that fit the data.
(\bar{x} - \mu_0) \pm t^{*}_{df} \times SE =-0.50 \pm 2.023 \times 0.190= [−0.88, −0.12]
t^{*}_{39} = 2.023 is the cutoff that holds the middle 95% of a t distribution with 39 df; software or a t table gives it (the normal curve's is 1.96). 2.023 × 0.19 = 0.38 hours, so the range is −0.50 ± 0.38, from −0.88 to −0.12 hours.
-
8. Ask How Surprising the Result Would Be If There Were No Real Difference
Finally, ask how often a t at least this far from zero, in either direction, would turn up if the true average were exactly 7.
p = 2 \times P(T_{df} \le -|t|) =2 \times P(T_{39} \le -2.64)= .012
P(T_{39} \le -2.64) is the chance that a t with 39 df lands at or below −2.64. Software (or a t table) gives this area. Doubling it counts both directions, .012, about 1 in 83.
Run It in Software
The code below reads the running example's data from data.csv; save it in the same folder you run the code from.
SPSS (version 30, as documented by IBM)
- Analyze → Compare Means and Proportions → One-Sample T Test.
- Move
hours_sleptinto Test Variable(s). - Set Test Value to 7.
- Leave Estimate effect sizes checked, and click OK.
Or paste this syntax:
T-TEST /TESTVAL=7 /MISSING=ANALYSIS /VARIABLES=hours_slept /ES DISPLAY(TRUE) /CRITERIA=CI(.95).
Reading the Output
SPSS prints three tables. The first, One-Sample Statistics, repeats N, the mean, SD and SE; the two below carry the test. Read them in this order: Mean Difference, then Cohen's d, then the 95% Confidence Interval, then Two-Sided p. Use the one-sided p only if you predicted the direction before collecting data.
One-Sample Test (Test Value = 7)
| t | df | One-Sided p | Two-Sided p | Mean Difference | 95% CI Lower | Upper | |
|---|---|---|---|---|---|---|---|
| hours_slept | -2.636 | 39 | .006 | .012 | -.500 | -.884 | -.116 |
One-Sample Effect Sizes
| Standardizer | Point Estimate | 95% CI Lower | Upper | |
|---|---|---|---|---|
| Cohen's d | 1.200 | -.417 | -.738 | -.091 |
| Hedges' correction | 1.223 | -.409 | -.723 | -.089 |
“Hedges' correction” is Cohen's d adjusted for small-sample bias. At n = 40 the two barely differ.
Output laid out from this page's computed results, not captured from a live run; labels and layout may differ slightly in your version.
R
sleep <- read.csv("data.csv")
t.test(sleep$hours_slept, mu = 7)
# Cohen's d
(mean(sleep$hours_slept) - 7) / sd(sleep$hours_slept)
One Sample t-test
data: sleep$hours_slept
t = -2.6357, df = 39, p-value = 0.01199
alternative hypothesis: true mean is not equal to 7
95 percent confidence interval:
6.11629 6.88371
sample estimates:
mean of x
6.5
[1] -0.4167409
R's interval is for the mean (6.12 to 6.88 hours) rather than for the difference from 7. It's the same interval, shifted by 7.
Output from a real run: R 4.6.1, run 2026-09-29.
Python
import pandas as pd
from scipy import stats
sleep = pd.read_csv("data.csv")
result = stats.ttest_1samp(sleep["hours_slept"], popmean=7)
result.statistic # -2.6357
result.pvalue # 0.01199
result.df # 39
result.confidence_interval() # (6.1163, 6.8837)
Output from a real run: Python 3.9.6 (scipy 1.13.1, pandas 2.3.3), run 2026-09-29.
Impact
Effect Size
Cohen's d expresses the difference in standard deviations, so it can be compared across studies that used different scales.
Students slept half an hour less than 7 hours, which is 0.42 of the usual spread between students, a small effect by convention.
Benchmarks are conventions. Whether 30 fewer minutes of sleep a night matters is a question about sleep, not statistics.
Benchmarks Cohen's d at a Glance
Statistical Significance
p answers one narrow question: if the null hypothesis were true, how often would t land at least this far from zero, in either direction? Put another way, how often would a sample mean land at least this many of its own standard errors from the comparison value? Below the conventional α = .05, the result is called statistically significant.
If students really averaged 7 hours, a sample mean at least 2.64 standard errors from 7, in either direction, would turn up about 1.2% of the time, roughly 1 in 83. That's below .05, so it's significant.
p is not the probability that the null hypothesis is true, and it says nothing about how large or important the difference is. That's what the effect size and interval are for.
Benchmarks p at a Glance
Strength of evidence against the null hypothesis.
Power and Sample Size
Power is the chance that a study detects an effect that's really there. A real effect doesn't guarantee a significant result: with too few people, it can easily come out non-significant. Power depends on four things: how big the true effect is, how many people you have, α, and whether the test is one- or two-sided.
Suppose, before collecting any data, we decided a gap of half a standard deviation from 7 hours (|d| = 0.5) would matter. For 80% power we'd need 34 students; with 34, if the true gap is that size, the study comes out significant about 81% of the time and misses it about 19% of the time.
Researchers usually aim for at least 80% power. Plan it before collecting data, using the smallest effect that would matter. Try it:
Other Info
Follow-Up and Post Hoc Tests
None needed. This test answers a single question, so there are no planned contrasts or post hoc tests to run.
References
- Student. (1908). The probable error of a mean. Biometrika, 6(1), 1–25. https://doi.org/10.2307/2331554
- Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.
-
Muff, S., Nilsen, E. B., O'Hara, R. B., & Nater, C. R. (2022). Rewriting results sections in the language of evidence. Trends in Ecology & Evolution, 37(3), 203–210.
https://doi.org/10.1016/j.tree.2021.10.009
“we suggest language of evidence that allows for a more nuanced approach to communicate scientific findings as a simple and intuitive alternative to statistical significance testing” (Abstract)
Spot an error? Something still confusing? Tell us at support@statsforpsychology.com.