The t student test, written more often as Student's t-test, checks whether the difference between two averages, or between one average and a reference value, is bigger than random sampling noise would produce. You divide the observed difference by its standard error to get a t statistic, then convert that statistic to a p-value. A small p-value says the difference is unlikely to be chance alone.
The test comes in three versions: one-sample, independent two-sample, and paired. Picking the wrong version is the most common mistake, and misreading the p-value is the second. This article explains why the test matters, how to choose a version, how the t-test formula works in a full calculation, and how to interpret what comes out.
PlotStudio AI is an analysis workspace for researchers, and group comparisons like this one are routine work there. So the last section also shows how to run the test in code and in PlotStudio, while the decision about whether the test fits your data stays with you.
Why Student's t-test matters
The t-test matters because averages from small samples bounce around, and the test tells you whether an observed gap is larger than that bounce. Without it, a 9-point difference between two groups of 10 looks like a finding when it may be luck.
The question it answers
William Sealy Gosset described the test in 1908 under the pseudonym "Student" while working for a brewery. He needed reliable conclusions from small samples. The test scales the difference in means by the variability in the data and by the sample size, so a gap counts as large only when it is large relative to the noise.

A t-test asks one thing: is this difference in means large compared with the noise in the data?
You will meet it in treatment comparisons, lab experiments and survey subgroups, because it works with the sample sizes real studies produce. The same logic also underlies t-tests for correlation coefficients and regression terms, so learning it pays off well beyond two-group comparisons.
What it assumes
Student's t-test is only as trustworthy as its assumptions. Check these before you run it:
- The outcome is continuous, such as a score, a concentration or a time.
- Observations are independent and come from a random sample.
- The data are roughly normal, or for a paired test, the differences are. This matters most when the sample is small.
- The groups have similar variances, for the classic independent version.
The test tolerates mild departures from these conditions. With heavy skew and a small sample, though, a rank-based alternative such as the Mann-Whitney test is the safer choice.
How to choose between the three t-tests
Choose by study design: one group against a known value is a one-sample test, two unrelated groups call for an independent test, and the same subjects measured twice call for a paired test. The data layout often tells you which one you have.
The three versions side by side
| Version | Compares | Example | Degrees of freedom |
|---|---|---|---|
| One-sample | One group mean against a fixed value | Mean waiting time against a 60-minute target | n − 1 |
| Independent two-sample | Means of two unrelated groups | Scores in a treatment group and a control group | n1 + n2 − 2 |
| Paired | Mean of within-pair differences against zero | Blood pressure before and after treatment | n − 1 (n = number of pairs) |

In a paired design, each subject serves as their own control. That removes between-subject variability and usually gives you more power than treating the same data as two independent groups. If both columns measure the same thing on the same people, you almost certainly need the paired version.
Student versus Welch, tails, and more than two groups
"T-test" is the family name, and "Student's t-test" strictly means the version that assumes equal variances in both groups. Welch's t-test drops that assumption and loses little when variances are equal, so make it your default for independent samples unless you have a reason not to.
Use a two-tailed test unless a difference in one direction is logically impossible, and decide that before you see the data. If you have more than two groups, do not run repeated t-tests, because each extra test inflates the false-positive risk. Use ANOVA followed by a post hoc test instead.
The t-test formula and a worked calculation
Every t-test formula has the same shape: the difference divided by its standard error. Only the numerator and the standard error change between versions, so once you see the pattern, the t-test calculation is the same for all three.
Every t-test formula is a difference divided by its standard error.
The three formulas
One-sample: t = (x̄ − μ0) / (s / √n) df = n − 1
Independent: t = (x̄1 − x̄2) / (sp × √(1/n1 + 1/n2)) df = n1 + n2 − 2
sp² = ((n1 − 1)s1² + (n2 − 1)s2²) / (n1 + n2 − 2)
Paired: t = d̄ / (sd / √n) df = n − 1
Here x̄ is a sample mean, s a sample standard deviation, n a sample size and μ0 the reference value. In the paired formula, d̄ and sd are the mean and standard deviation of the differences. In the independent formula, sp is the pooled standard deviation, a weighted blend of both groups' variances.
Worked example: independent samples
Say 10 students per group take a test after two teaching methods. Group A has a mean of 78 and an SD of 8. Group B has a mean of 69 and an SD of 9.

- Pool the variance: sp² = (9 × 64 + 9 × 81) / 18 = 72.5, so sp ≈ 8.52.
- Compute the standard error: 8.52 × √(1/10 + 1/10) ≈ 3.81.
- Compute t: (78 − 69) / 3.81 ≈ 2.36, with df = 10 + 10 − 2 = 18.
- Compare with the critical value for df = 18 at α = 0.05, two-tailed, which is 2.101.
Because 2.36 exceeds 2.101, you reject the null hypothesis of equal means. The two-tailed p-value is about 0.03.
How to interpret t-test results
Compare the absolute t value with the critical value for your degrees of freedom, or compare the p-value with the significance level you chose in advance, usually 0.05. If |t| is larger than the critical value, or p is smaller than α, you reject the null hypothesis.
Reading t, degrees of freedom, and p
There is no universal "good" t score, because the bar depends on degrees of freedom. With very small samples you need a larger t to reach significance.
| Degrees of freedom | Critical t (α = 0.05, two-tailed) |
|---|---|
| 5 | 2.571 |
| 10 | 2.228 |
| 18 | 2.101 |
| 30 | 2.042 |
| 120 | 1.980 |
The p-value is the probability of data at least this extreme if the null hypothesis were true. It is not the probability that the null is true, and it says nothing about whether the effect is important. The sign of t only tells you which group is larger.
A p-value tells you whether a difference is detectable, not whether it matters.
Reporting more than the p-value
Add a confidence interval and an effect size. In the worked example, the mean difference is 9 points, with a 95% CI of 9 ± 2.101 × 3.81, or 1.0 to 17.0 points. Cohen's d is 9 / 8.52 ≈ 1.06, a large effect.
The standard report line is t(18) = 2.36, p = 0.03. The interval is wide, so the result is significant but imprecise. Say so in your write-up, and let the interval temper your conclusion.
How to run a t-test in code or in PlotStudio AI
You can run any version in one line of Python or R, or describe the comparison in plain English in PlotStudio AI. Either way, the software computes the numbers and you check the design and assumptions.
Python and R
# Python (SciPy)
from scipy import stats
stats.ttest_1samp(x, popmean=60) # one-sample
stats.ttest_ind(a, b, equal_var=False) # Welch; True = Student
stats.ttest_rel(before, after) # paired
# R
t.test(x, mu = 60) # one-sample
t.test(score ~ group, data = df, var.equal = TRUE) # Student; default is Welch
t.test(before, after, paired = TRUE) # paired
Check the variance argument first, because Python and R default to different behavior. SciPy's default is the pooled Student version, while R's t.test defaults to Welch.
Running it in PlotStudio AI
In PlotStudio AI, you upload your dataset and ask for the comparison in plain English. The AI agents plan the analysis, write and run the Python, and report the statistics with an interpretation. Verification Mode lets you review the plan and approve the method and assumptions before anything runs, and you can inspect the generated code afterward.
Software computes the t statistic, but you decide whether the test fits your design.
The free trial includes 30 credits and needs no credit card or API key, so you can test it on a dataset you already know the answer to.
Putting the t-test to work
Student's t-test divides a difference in means by its standard error and asks whether the result is larger than chance would produce. Choose the version by design: one-sample, independent or paired. Default to Welch's for unequal variances, use two tails unless one direction is impossible, and switch to ANOVA for more than two groups.
When you read the output, look past the p-value. The t statistic against its critical value, the confidence interval and the effect size together tell you how large and how precise the difference is. If you want to run these tests on your own data and see the code behind every step, try PlotStudio AI with the free trial.
