
Dan Patiño
AI Strategy & Innovation at Coderhouse
Data
A t-test is a statistical test that checks whether the difference between two averages is larger than you would expect from random variation alone. Did customers who saw the new checkout spend more per order than those who saw the old one? Is the average resolution time different between two support teams? A t-test gives analysts a structured way to answer questions like these instead of eyeballing two numbers on a dashboard.
It is one of the most common tools in a data analyst’s kit because so many business questions boil down to comparing means. Understanding which version of the test to use, what assumptions it makes and how to read its output is what separates a defensible conclusion from a lucky guess.
What is a t-test?
A t-test compares means and produces a t-statistic: the difference between the means divided by an estimate of how much that difference would vary by chance (the standard error). The bigger the t-statistic in absolute value, the less likely the difference is just noise.
The t-statistic is converted into a p-value using the t-distribution. If the p-value falls below the significance level you chose in advance (often 0.05), you reject the null hypothesis that the means are equal. If you need a refresher, see our guides on hypothesis testing and what a p-value really means.
The NIST/SEMATECH Engineering Statistics Handbook describes the two-sample t-test as a way to determine whether two population means are equal, and documents both the equal-variance and unequal-variance versions of the formula.
The three main types of t-test
One-sample t-test
Compares the mean of one group against a fixed reference value. Example: is the average delivery time this month different from the 3-day promise?
Independent (two-sample) t-test
Compares the means of two separate groups. Example: average order value for users in variant A vs. variant B of an experiment. There are two flavors:
Student’s t-test assumes both groups have the same variance.
Welch’s t-test does not assume equal variances and is usually the safer default in business data, where groups often differ in size and spread.
Paired t-test
Compares two measurements taken on the same units. Example: the same sales reps’ weekly calls before and after a new tool rollout. Because each unit acts as its own control, the paired test focuses on the within-unit differences.
Assumptions to check before running a t-test
Independence: observations should not influence each other (one row per user, not one row per page view from the same user).
Roughly normal sampling distribution: with small samples, the data itself should be close to normal; with larger samples, the central limit theorem makes the test fairly robust.
Scale of measurement: the outcome should be numeric and continuous-ish (revenue, time, scores), not categories. For categorical outcomes like “converted / did not convert”, a test such as the chi-square test is a better fit.
Outliers: extreme values can dominate a mean. Check for them before trusting the result.
How analysts run a t-test in practice
In Python, SciPy covers the common cases. The scipy.stats.ttest_ind function runs an independent two-sample test, and setting equal_var=False switches it to Welch’s version. For paired data, scipy.stats.ttest_rel handles related samples. Spreadsheets offer a T.TEST function, and most BI and experimentation tools run t-tests behind the scenes.
A typical workflow looks like this:
Define the question and hypotheses before looking at results.
Pick the test: one-sample, independent (Welch by default) or paired.
Clean the data: deduplicate, define the unit of analysis and inspect outliers.
Run the test and record the t-statistic, degrees of freedom and p-value.
Report the effect size and a confidence interval for the difference, not just whether it is “significant”.
Reading the result without fooling yourself
Significant is not the same as important. With very large samples, tiny differences become statistically significant. Always ask whether the size of the difference matters to the business.
Not significant does not mean “no difference”. It may mean the sample was too small to detect it. Planning sample size with statistical power avoids underpowered tests.
Don’t peek and stop early. Checking results repeatedly and stopping when p dips below 0.05 inflates false positives.
Watch multiple comparisons. Running many t-tests on the same data raises the chance that one looks significant by luck. For three or more groups, consider ANOVA instead.
FAQ
When should I use a t-test instead of a z-test?
Use a t-test when the population standard deviation is unknown and estimated from the sample, which is almost always the case in business analysis. With large samples, the two give very similar results.
Should I use Student’s or Welch’s t-test?
Welch’s is a sensible default because it does not require equal variances and loses little when variances are actually equal.
Can I use a t-test for conversion rates?
Conversion is a proportion, so tests designed for proportions or the chi-square test are usually more appropriate. A t-test fits continuous metrics like revenue per user or time on task.
Keep learning with Coderhouse
Comparing groups correctly is a core skill for anyone who makes decisions with data, from analysts to AI and go-to-market teams. Explore the three programs:
Data Analytics Course — learn SQL, Python, statistics and dashboards to run and explain analyses like this one.
Forward Deployed AI Engineering Course — learn to build and deploy AI agents and applications that connect to real business tools and data.
GTM Engineer Course (waitlist) — join the waitlist for early access to the program focused on automated go-to-market systems.
I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.