1-Sample t-Test


Input Sample Data

In order to do a 1-sample t-test, we first need to provide our single (one) sample that we will be analysing. Below you can choose pre-uploaded data to analyse, or you can manually enter data.


What data source will you be using?



Enter data into the text box below.

  • All values must be numeric, and numbers should contain no spaces or any characters other than a . for a decimal place.
  • Each value must be on its own line, or comma separated.
  • Don't forget to press 'Upload' once you are finished!

Warning: You must have at least two unique values in your manually specified data.


In order to proceed, you must select some data to act as your sample.




The 'NULL' Hypothesis - Setting up the Box

We start by using the box model to represent our null hypothesis.

The only thing we need to do to set up the box in this test is specify the sample data (which we have already done) and specify the null hypothesis. In this test we are focusing on the mean, so the null hypothesis is that the population mean is equal to some value which we set below.

Given \(\mu \), where \(\mu \) is the population mean of the variable being analysed:

\( H_0: \) \(\mu = \)

In case you are confused about where all the values in the diagram have come from, these come from the sample data that you previously specified. In particular:

  • The box is labelled \(\sigma \approx s \). Read this as: the box's real spread \(\sigma \) is unknown, so we are standing the sample's standard deviation \(s \) in for it. Unlike the 1-sample z-test, which requires that \(\sigma \) is genuinely known, the 1-sample t-test drops that requirement — it uses \(s \) and then compensates by finding the p-value from the t-distribution rather than the normal. The \(\approx \) is doing real work: \(s \) is an estimate, not the true value, and everything that follows is arranged around that.
  • The value for \(n \) comes from the number of values in the sample chosen above.
  • The observed value (\(\text{OV} \)) comes from the mean of the sample chosen above.



The Alternate Hypothesis

Specify what type of alternate hypothesis you will be using below:


Null Hypothesis

Alternate Hypothesis




Assumptions

For the hypothesis test to be valid, we need to check the following assumptions:

The first assumption is that our sample is independent and randomly chosen from the population we want to draw a conclusion about.

How do we check? We check by investigating the experimental setup. No plot or number on this page can tell us whether this holds — it is a question about how the data was collected.

In Mr. Han's case study the assumption is satisfied: the board handed him 25 papers drawn at random from across the country, so every student who sat the exam was equally likely to be in his pile, and one paper landing there tells us nothing about which others did. With real data you would read the methodology section of the accompanying publication and ask exactly this question of it.

The second assumption is that the sample mean follows a normal distribution — that is, if we kept drawing fresh samples of this size from the box and recorded each sample mean, those means would form a normal curve. Note that the assumption is about the sample mean, not about the individual values.

How do we check?

Idea 1: Large n

  • Recall that the central limit theorem tells us that if we take a sufficiently large number of draws from the box, then the sample means will approximately follow a normal distribution, whatever shape the values in the box have. If confused, please do the exercise at Fundamentals > Box Model Part 2.
  • One way to gauge whether the central limit theorem holds or not is to see how large our sample is (this is indicated by the "n" in the box model above).
  • Many textbooks will say that you can use the rule of thumb that the central limit theorem will apply if we have 30 or more draws. BEWARE - this is not always true! If the distribution of the values is very skewed, you will need much more than 30 draws!

Idea 2: QQ-plot, Boxplot and Histogram
The other route is the shape of the data itself. The central limit theorem is what rescues us when the values in the box are not normal. If they are already normal, we do not need it at all: the sample mean is then exactly normal for any sample size. So the closer our data looks to normal, the less we are leaning on a large n.

  • (QQ-plot) If the sample closely follows the QQ line, it suggests the data is normally distributed, and the assumption is on firm ground regardless of n.
  • (Boxplot and Histogram) If the data is symmetric, fewer points are needed for the central limit theorem to do its job. These plots can also be used to indicate whether the data appears to be normally distributed.

You might reasonably ask: if the sample mean is normal, why does this test not use a normal curve? The answer is the one difference between this test and the z-test. There, the population standard deviation \(\sigma \) was known, so the standard error was a known quantity too. Here \(\sigma \) is unknown and the sample's own standard deviation \(s \) stands in for it. That substitution is what the t-curve below exists to account for.




Test Statistic

Step 1) Calculate Expected Value (EV) and Standard Error (SE)

Step 2) Test Statistic Calculation




p-value



Conclusion (p-value)

One way to tell whether we reject the null hypothesis is to observe whether our p-value is below or above the significance level.

Step 1) What is your significance level?

\( \alpha = \)

Error: The value for α must be strictly between 0 and 1. Reverted to 0.05.

Step 2) Final Conclusion




Conclusion (Confidence Interval)

A confidence interval gives us a second route to the same decision. It is built around our observed sample mean and gives a plausible range for the unknown population mean. If the null hypothesis value falls outside that range, the null value is not among the plausible ones, and we reject the null hypothesis.

Step 1) Where does the confidence level come from?

There is nothing to set here. The confidence level is not a free choice alongside \(\alpha\) — it is determined by it:

\( \text{confidence level} = 1 - \alpha \)

This matters. The confidence interval and the p-value are two ways of reading the same calculation, so they always reach the same verdict — but only when they are set up to describe the same test. That means using \(1 - \alpha\) as the level, and matching the interval to the alternate hypothesis: a two-sided interval for a two-sided test, and a one-sided interval for a one-sided test. Both are done for you below. If you change \(\alpha\) or the alternate hypothesis above, the interval here follows.

Step 2) Final Conclusion