T-Test Calculator

Perform one-sample and two-sample t-tests for hypothesis testing. Calculate t-statistics and determine statistical significance.

Quick Facts

Common Alpha
0.05 (5%)
Standard significance level
Decision Rule
Reject H0 if p < alpha
Or if |t| > critical value
Welch's T-Test
Used Here
No equal variance assumption
Two-Tailed Test
Default
Tests difference in either direction

T-Test Results

Calculated
T-Statistic
0
Test statistic
P-Value
0
Two-tailed
Degrees of Freedom
0
df
Sample 1 Mean
0
SD: 0
Sample 2 Mean
0
SD: 0
Critical Value
0
at alpha = 0.05

Statistically Significant

The difference between the means is statistically significant at the chosen significance level.

Frequently Asked Questions

What does the t-statistic mean?

The t-statistic measures how many standard errors the sample mean is from the hypothesized mean. Larger absolute values indicate stronger evidence against the null hypothesis.

Can I use a t-test with non-normal data?

The t-test is robust to moderate non-normality, especially with larger samples. For severely skewed data or small samples, consider transformation or non-parametric alternatives.

What if my groups have different sizes?

Unequal sample sizes are fine. Welch's t-test handles unequal sizes and variances appropriately.

Why use Welch's instead of Student's t-test?

Welch's t-test doesn't assume equal variances, making it more robust and applicable in most situations. It provides accurate results whether variances are equal or not.

What is a t-test and when should I use it?
A t-test is a statistical hypothesis test used to determine whether there is a significant difference between the means of one or two groups. It was developed by William Gosset (writing as "Student") in 1908, hence "Student's t-test." When to use a t-test: Use a t-test when you want to compare means and your data: Is continuous (interval or ratio scale). Is approximately normally distributed (or sample size is large enough for the Central Limit Theorem to apply). Has homogeneous variances (for independent samples — Welch's correction handles unequal variances). Is independent between observations within groups. Types of t-tests: One-sample t-test: Compare your sample mean against a known or hypothesized population mean. Example: Is the average delivery time from a company equal to their claimed 3 days? Independent (two-sample) t-test: Compare means of two separate, unrelated groups. Example: Do men and women have different average blood pressure? Paired t-test: Compare means from the same individuals at two time points (or matched pairs). Example: Does a drug lower blood pressure compared to placebo (same patients measured twice)? When NOT to use a t-test: More than two groups → use ANOVA. Non-normal data with small samples → use Mann-Whitney U (non-parametric). Categorical outcomes → use chi-squared test. More than one independent variable → use multiple regression or factorial ANOVA.
What does the p-value mean in a t-test?
The p-value is the probability of observing a result as extreme as (or more extreme than) your data, assuming the null hypothesis is true. Common misunderstanding: The p-value is NOT the probability that the null hypothesis is true. It is the probability that your data (or more extreme data) would occur if the null hypothesis were true. Interpreting the p-value: p < 0.05: Results are "statistically significant" at the 5% level. You reject the null hypothesis. p < 0.01: Stronger evidence; significant at the 1% level. p ≥ 0.05: Fail to reject the null hypothesis. This does NOT prove the null is true. It means you don't have enough evidence to conclude a difference exists. The significance threshold (α): The most common threshold is α = 0.05, meaning you accept a 5% chance of a false positive (Type I error). In high-stakes research (medical, safety-critical), α = 0.01 or 0.001 is used. In exploratory research, α = 0.10 may be acceptable. Important limitations: Statistical significance ≠ practical significance. A large enough sample can make a trivial difference statistically significant. Always report effect size (Cohen's d) alongside the p-value. Multiple comparisons: Running many t-tests inflates the false positive rate. If you run 20 tests at α = 0.05, expect 1 false positive just by chance. Use Bonferroni correction or a family-wise error rate correction. One-tailed vs. two-tailed: Two-tailed: Tests whether means differ in either direction (most common). One-tailed: Tests whether one mean is specifically greater than the other (use only when direction is pre-specified).
What is the difference between paired and unpaired t-tests?
The choice between paired and unpaired (independent) t-tests depends on how the data was collected — specifically, whether the two sets of measurements are related to each other. Independent (unpaired) t-test: Used when the two groups contain different individuals with no relationship between them. Examples: Heights of men vs. women. Test scores of two different classes. Blood pressure of treatment group vs. control group (different people). Paired t-test: Used when the same individuals (or matched pairs) provide both measurements. Examples: Patient blood pressure before and after treatment (same patients). Student scores on pre-test and post-test (same students). Twins assigned to different diets (matched pairs). Why the distinction matters: Paired data has less variability because within-subject effects are controlled. The paired t-test is more powerful (can detect smaller differences) when the pairing is relevant. Using an unpaired test on paired data wastes statistical power. Using a paired test on independent data is incorrect and gives wrong results. Example: A drug study. Correct (paired): Measure each patient before and after treatment → use paired t-test. Correct (unpaired): Randomly assign 50 patients to drug, 50 to placebo → use independent t-test. Wrong: Treating the same patients' before/after as independent groups → inflates sample size and p-value. Quick check: "Are the observations in group 1 directly linked to observations in group 2?" If yes → paired. If no → independent.
What sample size do I need for a t-test?
Sample size requirements depend on your desired statistical power, significance level (α), and expected effect size. Key concepts: Statistical power (1 − β): The probability of detecting a real effect if it exists. Typical target: 80% power (β = 0.20). Effect size (Cohen's d): Small: d = 0.2 (requires very large samples). Medium: d = 0.5 (manageable sample sizes). Large: d = 0.8 (relatively small samples). Rule of thumb sample sizes (per group, two-sample t-test, α = 0.05, 80% power): Small effect (d=0.2): ~200 per group (400 total). Medium effect (d=0.5): ~33 per group (66 total). Large effect (d=0.8): ~13 per group (26 total). One-sample t-test (80% power, α = 0.05): Small (d=0.2): ~200. Medium (d=0.5): ~35. Large (d=0.8): ~14. Paired t-test: Generally requires fewer subjects than independent t-test for the same effect size, because within-subject correlation reduces variance. Practical implications: Don't run a study with an inadequate sample size — underpowered studies produce unreliable results and waste resources. Pre-register your sample size calculation before collecting data. If you don't know the expected effect size: Use previous literature to estimate. Run a pilot study with n=10–20 per group. Use a conservative estimate (small-medium effect size) to ensure adequate power. The Central Limit Theorem: For n ≥ 30 per group, the t-test is robust to non-normality. For very small samples (n < 10), normality is critical and should be checked.

What is a T-Test?

Scenario Test Type Example
Compare sample mean to known valueOne-sample t-testIs a factory's average output = target?
Compare two independent groupsIndependent (unpaired) t-testMen vs. women on test scores
Compare same group at two time pointsPaired t-testBefore/after treatment measurements
More than two groupsANOVA (not t-test)Compare 3+ treatment groups
Non-normal data, small sampleMann-Whitney U (non-parametric)Ranked data or severe outliers
Categorical outcomesChi-squared testNot a t-test scenario
Degrees of Freedom (df) α=0.05 (two-tailed) α=0.01 (two-tailed) α=0.001 (two-tailed)
52.5714.0326.869
102.2283.1694.587
202.0862.8453.850
302.0422.7503.646
602.0002.6603.460
1201.9802.6173.373
∞ (z)1.9602.5763.291
Cohen's d Value Effect Size Interpretation
0.2SmallSmall but detectable difference
0.5MediumMeaningful in many contexts
0.8LargeClearly noticeable difference
1.2Very largeVery strong effect
2.0+HugeRare in social/behavioral research
Rule of thumbd = (M₁ − M₂) / SD_pooledSD_pooled = √((SD₁² + SD₂²)/2)

A t-test is a statistical hypothesis test used to determine whether there is a significant difference between the means of groups. Developed by William Sealy Gosset under the pseudonym "Student," the t-test is one of the most widely used statistical procedures for comparing means when sample sizes are small and population variance is unknown.

T-tests are essential tools in scientific research, quality control, medicine, and social sciences. They help researchers determine whether observed differences between groups are statistically significant or likely due to random chance.

Types of T-Tests

One-Sample T-Test

Compares the mean of a single sample to a known or hypothesized population mean. Use this when you want to test whether your sample comes from a population with a specific mean.

One-Sample T-Test Formula

t = (x-bar - mu0) / (s / sqrt(n))
x-bar = Sample mean mu0 = Hypothesized population mean s = Sample standard deviation n = Sample size

Two-Sample T-Test (Independent Samples)

Compares the means of two independent groups to determine if they are significantly different. This calculator uses Welch's t-test, which does not assume equal variances.

Welch's T-Test Formula

t = (x-bar1 - x-bar2) / sqrt(s1^2/n1 + s2^2/n2)
Degrees of freedom (Welch-Satterthwaite): df = (s1^2/n1 + s2^2/n2)^2 / [(s1^2/n1)^2/(n1-1) + (s2^2/n2)^2/(n2-1)]

Paired T-Test

Compares means from the same group at different times or under different conditions. Used for before-after studies or matched pairs. This calculator handles paired data by computing differences and performing a one-sample t-test on those differences.

Hypothesis Testing with T-Tests

Setting Up Hypotheses

Every t-test involves a null hypothesis (H0) and an alternative hypothesis (H1):

Test Type Null Hypothesis (H0) Alternative (H1)
One-samplemu = mu0mu != mu0
Two-samplemu1 = mu2mu1 != mu2
Pairedmu_d = 0mu_d != 0

Significance Level (alpha)

The significance level is the probability of rejecting the null hypothesis when it is true (Type I error). Common choices:

  • alpha = 0.05: 5% chance of false positive (most common)
  • alpha = 0.01: 1% chance (more conservative)
  • alpha = 0.10: 10% chance (more lenient)

Decision Rule

Compare the calculated t-statistic to the critical value from the t-distribution table:

  • If |t| > t_critical: Reject H0 (significant difference)
  • If |t| <= t_critical: Fail to reject H0 (no significant difference)

Degrees of Freedom

Degrees of freedom (df) determine which t-distribution to use:

Degrees of Freedom

One-sample: df = n - 1 Two-sample (equal var): df = n1 + n2 - 2 Welch's (unequal var): df calculated from variances Paired: df = n - 1 (where n = number of pairs)

Assumptions of T-Tests

Normality

The data should come from normally distributed populations. The t-test is robust to moderate departures from normality, especially with larger samples (n > 30). Use histograms or normality tests to check this assumption.

Independence

Observations should be independent of each other. For two-sample tests, the groups must be independent. This assumption is critical and cannot be violated.

Equal Variances (Student's t-test)

The classic two-sample t-test assumes equal population variances. Welch's t-test relaxes this assumption, making it more versatile and is recommended unless variances are known to be equal.

Practical Examples

Example 1: Drug Effectiveness

Treatment group: 85, 90, 88, 92, 87, 91

Control group: 78, 82, 80, 79, 81, 83

Question: Is the treatment significantly better than control?

Result: t = 4.21, df = 9.7, p < 0.05

Conclusion: Significant difference; treatment appears effective.

Example 2: Quality Control

Measured weights: 500.2, 499.8, 500.5, 499.5, 500.1

Target weight: 500g

Question: Is the machine calibrated correctly?

Result: t = 0.32, df = 4, p > 0.05

Conclusion: No significant difference from target.

Interpreting T-Test Results

Statistical vs. Practical Significance

A statistically significant result doesn't always mean a practically important difference. With large samples, even tiny differences can be significant. Always consider effect size alongside p-values.

Effect Size (Cohen's d)

Cohen's d measures the standardized difference between means:

  • d = 0.2: Small effect
  • d = 0.5: Medium effect
  • d = 0.8: Large effect

Common Mistakes to Avoid

Using the Wrong Test

Make sure you choose the appropriate test for your data structure. Use paired t-tests for matched pairs, not independent samples t-test.

Ignoring Assumptions

Check normality and variance assumptions before running the test. Consider non-parametric alternatives (Mann-Whitney U, Wilcoxon) if assumptions are severely violated.

Multiple Testing

Running multiple t-tests inflates the Type I error rate. Use ANOVA for comparing more than two groups, or apply corrections like Bonferroni.

T-Test vs. Z-Test

Feature T-Test Z-Test
Sample SizeAny sizeLarge (n > 30)
Population sigmaUnknownKnown
Distributiont-distributionNormal
What sample size do I need for reliable results?
It depends on the desired confidence level, margin of error, and population variance. For a typical survey (95% confidence, ±5% margin), n ≈ 385 for a large population. Smaller samples are fine for exploratory analysis, but don't over-interpret the results — widen your confidence intervals to reflect the uncertainty.