T-Test Explained: Types, Formula and Worked Examples

A t-test evaluates a claim about a population mean by comparing an estimated difference with its standard error. It is useful when the population standard deviation is unknown and the test's sampling assumptions are reasonable. Different versions address one sample, two independent samples, or paired observations.
The result is evidence about a specified mean difference under a model. It is not the probability that an investment strategy works, and it does not establish that a small average advantage will survive costs or future market conditions.
What Is a T-Test?
The test statistic measures how far the observed estimate sits from a hypothesized value, in units of estimated sampling uncertainty. The NIST t-test reference presents the one-sample, independent-sample, and paired forms.
The basic pattern is:
t = (estimated mean difference − hypothesized difference) / standard error.
A larger absolute t statistic means the estimate is farther from the null value relative to the estimated noise. Its interpretation depends on degrees of freedom, which determine the reference t distribution.
Start by defining the quantity you want to compare. A strategy's return, a change in a forecast score, and the difference between two fees are different measurements. They require compatible units and a sampling design that supports the intended comparison.
It also matters whether you planned the comparison before seeing the results. Selecting whichever of many tests looks most favorable changes how much confidence an isolated p value deserves.
Choose the T-Test That Matches the Data
| Test | Comparison |
|---|---|
| One-sample | Mean versus target |
| Independent | Two separate groups |
| Paired | Matched differences |
A one-sample test compares a sample mean with a fixed target. Its statistic is t = (mean − target) / (s / √n), where s is the sample standard deviation and n is the number of independent observations.
A paired test first subtracts one observation from its matched counterpart, then tests the mean of those differences. Matching might mean evaluating two forecasts for the same event or measuring an item before and after a change.
For independent groups, Welch's test allows their population variances to differ. Its standard error is √(s₁²/n₁ + s₂²/n₂). The pooled version makes an equal-variance assumption. NIST explains both approaches in its two-sample t-test guidance.
Do not use an independent-sample formula merely because you have two columns. If the entries describe the same events or matched units, the relationship between the columns can be important.
Worked Example: Eight Paired Return Differences
Suppose two hypothetical methods are evaluated over the same eight periods. Subtract method B's net return from method A's net return in each period. The differences, in percentage points, are:
2, 3, 1, 4, 0, 3, 2, 1.
For this teaching example, assume the eight differences are independent observations from an approximately normal population. That assumption is not a description of financial returns in general. Real return data can have outliers, changing volatility, and dependence over time.
Set the null hypothesis to a population mean difference of zero. Use a two-sided alternative and a 5% significance level, chosen before inspecting the result.
The differences sum to 16, so their mean is 2 percentage points. Their deviations from 2 have a squared sum of 12. The sample variance is 12/7, giving a sample standard deviation of about 1.3093 percentage points.
The standard error is 1.3093/√8, or about 0.4629 percentage points. The test statistic is therefore:
t = (2 − 0) / 0.4629 ≈ 4.3205.
There are 7 degrees of freedom, since the paired test uses eight differences and estimates their mean. These are eight paired observations, rather than 16 independent return measurements.
Interpret the P Value and Confidence Interval
For t ≈ 4.3205 and 7 degrees of freedom, the two-sided p value is approximately 0.0035. Under the stated assumptions, this is below the preselected 0.05 threshold.
The test therefore provides evidence against the zero-mean null in this example. It does not assign a 0.35% probability to the null hypothesis. Our p-value guide explains that distinction.
A 95% confidence interval for the population mean difference uses a t critical value of approximately 2.3646:
2 ± 2.3646 × 0.4629 ≈ 0.9054 to 3.0946 percentage points.
| Result | Value |
|---|---|
| Mean difference | 2 pp |
| t statistic | 4.3205 |
| Degrees of freedom | 7 |
| Two-sided p | 0.0035 |
The interval describes the uncertainty produced by this method and these assumptions. It is not a range that contains 95% of individual future returns. Nor does it account for uncertainty created by changing the strategy after examining the same data.
NIST's paired-observations explanation provides the underlying mean-difference and standard-error formulas. The figures above are an independent hypothetical calculation.

Assumptions to Check Before Using the Result
Independence is a property of the data-generating process, not a reward for having a large spreadsheet. Several rows might reflect overlapping positions, repeated measurements of one event, or returns affected by the same announcement.
For the paired example, assess the differences themselves. Inspect whether they contain extreme outliers or a pattern inconsistent with the assumed reference distribution. With only eight observations, one unusual value can have substantial influence.
For independent groups, ask how the groups were formed and whether observations within them are independent. Choosing Welch's formula addresses unequal variance; it does not repair biased sampling or dependence.
Also inspect how missing observations were handled. Removing the worst outcomes or the periods when a method could not trade changes the comparison. A clean-looking sample can still represent a selective part of the real process.
When these assumptions are not plausible, a different model or a design that handles dependence may be needed. Naming a more sophisticated test is not enough: its assumptions must match the question and the data too.
Statistical Significance Versus an Investable Advantage
A test about mean differences does not include every part of an investment decision. Transaction costs, funding, taxes, access to capital, execution, and the timing of losses can matter even if the observed mean differs from zero.
If the differences are measured before costs, call them gross differences. If they are net, explain which expenses were included. Comparing a gross strategy return with a net benchmark creates a misleading advantage before any statistical test begins.
The example's 2 percentage points also needs context. It does not describe a universally available annual return. The periods and methods are hypothetical, and a positive average says little about the maximum loss a person might experience along the way.
Connect the estimate to a clear null hypothesis, a realistic benchmark, and data kept apart for later evaluation. For more than two groups, the ANOVA guide explains a different framework for comparing means.
Report a T-Test So Someone Else Can Check It
A useful report states the question, units, comparison direction, test version, sample size, and assumptions. Include the mean difference, standard error or confidence interval, degrees of freedom, t statistic, and p value.
Describe the sample-selection rule and whether the analysis was planned in advance. Record exclusions and adjustments for multiple testing where they apply. A reader should be able to reconstruct the comparison without guessing what the spreadsheet columns represent.
Keep full precision during the calculation and round only the displayed results. In the worked example, rounding the standard deviation to 1.3 before calculating t changes the final decimal places. That is a presentation issue worth preventing even when it does not alter the broad conclusion. Save the original observations alongside the reported results so a later reviewer can repeat the calculation.
Frequently Asked Questions
Is a T-Test Only for Small Samples?
No. It is often taught using small samples because uncertainty in the standard deviation matters visibly there. Larger samples do not remove the need for an appropriate sampling design or a well-defined comparison.
Does a Negative T Statistic Mean the Test Failed?
No. The sign reflects the subtraction order. In a two-sided test, evidence depends on the absolute distance from zero. A one-sided test also depends on whether the result points in the direction specified beforehand.
Does Failing to Reject the Null Prove Two Methods Are Equal?
No. An ordinary t-test can fail to detect a difference because the data are noisy or limited. Demonstrating practical equivalence requires an appropriate equivalence question, a specified tolerance, and a suitable analysis.