gizmobench

T-Test Calculator

Paste or import up to 10,000 values per list and this page runs a one-sample, paired or Welch two-sample t-test, then shows its working: the mean, SD, standard error, quartiles and skewness of every list, a dot plot or histogram of the data, t, the degrees of freedom, the p-value, the interval for the mean or mean difference, and Cohen's d. Welch [1, 2, 3] against [4, 5, 6] gives t = -3.674234614 on 4 degrees of freedom, two-sided p = 0.02131, and a 95% interval of -5.26696 to -0.733042. The means and variances are computed exactly from the digits you type rather than in floating point, which matters when a sample does not vary: [1.1, 2.2, 3.3] paired with [0.1, 1.2, 2.3] differs by exactly 1 every time, so the variance is zero and t is reported as undefined, where floating point leaves the differences unequal in their last digit and can turn them into a t near 1.1e16.

Your data

Test

Compares two independent means without assuming equal variances.

Alternative

ResultWelch two-sample t-testExample data

123456AB95%-5-4-3-2-10

Text equivalent: Dot plot of A: 3 values from 1 to 3, mean 2. Dot plot of B: 3 values from 4 to 6, mean 5. 95% interval -5.26696 to -0.733042 for the difference in means, A - B, estimate -3, null 0.

Example data: two short samples, tested with Welch. Replace them with your own values and run the test.

t
-3.674234614
Degrees of freedom
4
p (two-sided)
0.02131
95% interval
-5.26696 to -0.733042

p = 0.02131 is below alpha = 0.05.

The 95% interval excludes the null value 0.

The test

TestWelch two-sample t-test, A against B, variances not assumed equal
Alternativetwo-sided: the difference in means, A - B differs from the null value 0
Estimate-3, the difference in means, A - B
Null value0
Standard error0.816497
t-3.674234614
Degrees of freedom4
p (two-sided)0.02131
95% interval-5.26696 to -0.733042
Cohen's d (average-variance SD)-3, from (difference in means - null) / sqrt((SD_A^2 + SD_B^2) / 2)

Samples

SummaryAB
n33
Left out (NA)00
Mean25
SD11
SE0.577350.57735
Min14
Q11.54.5
Median25
Q32.55.5
Max36
Skewness g100
Beyond 1.5 IQR00
  • The larger sample variance is 1 times the smaller.

Assumptions

  • The two samples are independent of each other, and the values within each are independent.
  • Each sample mean is close to normally distributed.
  • The variances are not assumed equal: each sample's own variance goes into the standard error, and the degrees of freedom come from the Welch-Satterthwaite approximation.
  • This page shows these assumptions and the summaries beside them; it does not test the assumptions or say whether they hold.

Worked cases

Each line is computed by the same code as the answer above. Load one to fill the boxes, then run it.

  • One-sample[2, 4, 6] against 0
    t 3.464101615, df 2, p 0.07418
  • Welch[1, 2, 3] against [4, 5, 6]
    t -3.674234614, df 4, p 0.02131
  • PairedSeven before and after pairs
    t 3.580141859, df 6, p 0.01164
  • Paired, unequal lengths[1, 2, 3] and [1, 2]
    Refused: Paired lists need the same number of entries, matched by position: A has 3 and B has 2. Add or remove entries so they line up, or use NA for a missing value.
  • Paired, equal differences[1.1, 2.2, 3.3] minus [0.1, 1.2, 2.3]
    t undefined: The 3 differences A - B have zero variance (every difference is 1), so the standard error is 0 and t is undefined.

Common questions

How do you calculate a t-test by hand?
Every version divides a difference by its standard error. For one list, t is the mean minus the null value, over the standard deviation divided by the square root of n, on n - 1 degrees of freedom: [2, 4, 6] against 0 has mean 4, SD 2 and standard error 1.1547, so t = 3.464101615 on 2 degrees of freedom and the two-sided p = 0.07418. A paired test does the same to the differences A - B. Welch divides the difference in means, less the null value, by the square root of each sample's variance over its size, added together. The page prints each of these figures, so every step can be checked.
Which t-test should I use: one-sample, paired or two-sample?
That depends on how the numbers were collected, which only you know. A one-sample test compares one list's mean with a fixed value you supply. A paired test is for two measurements of the same things, such as the same items before and after, matched by position: it tests the differences. Welch's two-sample test is for two separate groups whose values are unrelated to each other. The page runs whichever you choose and lists that test's assumptions beside the result; it does not choose for you.
Why does this use Welch's t-test instead of Student's?
Welch's version does not assume the two groups share a variance: each group's own variance goes into the standard error, and the degrees of freedom come from the Welch-Satterthwaite formula, so they are usually not a whole number. When both groups have the same size and the same variance the two versions agree: [1, 2, 3] against [4, 5, 6] gives t = -3.674234614 on exactly 4 degrees of freedom either way. The pooled Student version is not offered here.
Why does the calculator say t is undefined?
Because the arithmetic has no answer. A t needs a standard error, and the standard error is zero when nothing varies: for a one-sample or paired test that means every value or every difference is the same, and for Welch it means both samples are constant. It also cannot be estimated from fewer than two values. The page says which of these happened and still shows the summaries. The means and variances are exact on the digits typed, which is what makes the zero exact: [1.1, 2.2, 3.3] paired with [0.1, 1.2, 2.3] differs by exactly 1 each time, while floating point leaves the three differences unequal in the last digit and can turn them into a t near 1.1e16.
How accurate is the p-value, and how small can it get?
The p-value is the tail of the Student t distribution at the degrees of freedom shown, computed from the regularized incomplete beta function by a continued fraction. It was checked against 250-digit closed forms computed with bc for whole degrees of freedom and against scipy for fractional ones, and agrees with both within 1e-12. A p-value below 1e-300, where a double starts to lose digits and eventually rounds to 0, is printed from its logarithm instead, so it keeps four significant digits. A two-sided p is twice the smaller tail, capped at 1.
Can I paste data from a spreadsheet or open a CSV file?
Yes. Values can be separated by spaces, tabs, new lines, commas or semicolons, so a column copied from a spreadsheet pastes straight in, and NA marks a missing value. Open CSV file reads a comma, semicolon or tab separated file in the browser, with quoted cells and a header row, and lets you pick the columns for A and B. Blank cells become NA so pairs stay lined up, and a cell that is not a number is refused by its row and column rather than skipped. A number written with a thousands separator, such as 1,250, is refused too, because a comma also separates values. Nothing is uploaded.
What does the confidence interval tell me?
It is the estimate plus and minus the t critical value times the standard error, at the level set by alpha: 0.05 gives a 95% interval for the mean or the mean difference. For Welch [1, 2, 3] against [4, 5, 6] that is -5.26696 to -0.733042. A one-sided test gets a one-sided bound to match, such as -infinity to -1.25935 for the same data with the alternative Less. The page says whether the interval includes the null value and whether p is below alpha, and draws no conclusion from either.
What are the assumptions of a t-test, and does this check them?
The values must be independent, and the mean, or the mean of the differences, must be close to normally distributed, which holds when the data are roughly normal or there are enough of them. A paired test also needs the pairs lined up correctly, and Welch needs the two groups to be independent of each other. The page lists the assumptions for the test you ran and shows the quartiles, the skewness and how many values lie beyond 1.5 times the interquartile range, but it does not test the assumptions or judge whether they hold.
Does the page keep my data?
It remembers only the test type, the alternative and alpha in this browser, so the page opens the way you left it. The values stay in the page's memory and are gone when you close it, and the Start over button above the tool clears the remembered settings. Copy report and Download CSV hand the current result to your clipboard or your downloads; in the CSV, a sample name that begins like a spreadsheet formula is written with a leading apostrophe.

Classical t-tests under the assumptions displayed with each result; no clinical, hiring or investment decision recommendation. Means and variances are exact arithmetic on the digits entered, and p-values and intervals come from a Student t distribution matched to independent reference values within 1e-12. Zero variance and undersized samples are explicit: t is reported as undefined, never as a number.