One sample test for a mean
For years the terraces have averaged 5.8 tonnes of rice per hectare. Under a new water-sharing schedule, twelve plots average 6.15. Is that real evidence the mean has risen, when the spread of all yields is not known and has to be guessed from the same twelve plots?
Where you are 7 in Inference for means
When you reach for it
Someone claims a value for the mean of a quantitative variable in a population, and a sample is meant to test it. A rice cooperative in Bali farms several hundred terrace plots, and its records give a long-run mean yield of 5.8 tonnes per hectare (every number in this lesson is made-up data). This season it tries a new schedule for sharing irrigation water between the terraces. Wayan, who keeps the cooperative’s records, picks 12 plots at random and finds a mean yield of 6.15 tonnes per hectare.
That is above 5.8, but a sample mean never lands exactly on the population mean. The question is whether 6.15 is further from 5.8 than chance alone would plausibly carry it. The one-sample t test answers that. It uses the same reasoning as the test for a proportion, with one change: the population standard deviation \sigma is unknown, so the sample’s s_x stands in, and the statistic follows a The t distribution and degrees of freedom instead of the normal curve.
The lesson runs over two days. Part 1 carries out a full one-sided test. Part 2 adds two-sided tests, their exact match with the t interval, calculator and spreadsheet output, and a case where a condition fails.
The procedure
The parameter and the hypotheses. Name the parameter in context first: \mu is the mean yield, in tonnes per hectare, of all the cooperative’s plots under the new schedule. The null hypothesis gives the claimed value \mu_0; the alternative says what the investigator suspects, chosen before the data are seen (Null and alternative hypotheses):
The hypotheses are about \mu, never about \bar{x}, whose value is already known. The alternative may be \mu > \mu_0, \mu < \mu_0 or \mu \neq \mu_0.
The significance level. The cutoff \alpha is fixed before the data are seen, so the data cannot move it. Here \alpha = 0.05.
The conditions. These are the three from Conditions for one mean, the same ones the ginseng roots were checked against: a random sample or randomized experiment; a sample under 10\% of the population when sampling without replacement; and a population that is roughly normal or a sample large enough, judged from a plot of the data when n is under 30 (no strong skew, no outliers).
The test statistic. As in Test statistic, where the geothermal spa’s count was measured in standard deviations from the claim, the statistic counts standard errors between the sample result and the null value:
For a proportion, H_0 fixes p and with it the spread of \hat{p}. A claimed mean says nothing about the spread, so \sigma is estimated by s_x. That estimate wobbles from sample to sample, which is why, as the maple sap example in The t distribution and degrees of freedom showed, the statistic has heavier tails than the normal curve, with n - 1 degrees of freedom.
The p-value. The p-value (p-values and the significance level) is the probability, if H_0 were true, of a t at least as far out as the observed one in the direction H_a names: the upper tail for \mu > \mu_0, the lower tail for \mu < \mu_0, both tails for \mu \neq \mu_0. A calculator gives it with `tcdf(lower, upper, df)`, using 10^{99} for “no upper end”; a spreadsheet with `T.DIST.RT(t, df)` for an upper tail and `T.DIST.2T(|t|, df)` for two tails. A printed t table lists only a few tail areas per row, so it brackets the p-value between two columns.
Decision and conclusion. If the p-value is at most \alpha, reject H_0; otherwise fail to reject it (Deciding and concluding from a p-value). The conclusion is said in words about \mu, in context, naming \alpha and the p-value.
Part 2: two-sided tests and the interval. A two-sided test at level \alpha rejects exactly when |t| \ge t^*, the critical value of the (1 - \alpha) t interval. Multiply through by the standard error:
So the test rejects \mu_0 exactly when \mu_0 lies outside the interval (on an end counts as outside, since then the p-value equals \alpha). The match is exact because the test and the interval use the same standard error, \displaystyle s_x / \sqrt{n}, and the same t curve. For proportions it is not exact: the test’s standard deviation uses p_0 and the interval’s standard error uses \hat{p}, so near the edge the two can disagree.
Worked examples
Examples 1 to 3 belong to Part 1: one-sided tests carried out in full, including p-values read from a table. Examples 4 to 6 belong to Part 2: a two-sided test beside its interval, technology output, and a condition that fails.
Wayan’s yields under the new schedule
Wayan’s random sample of 12 plots gives these yields, in tonnes per hectare: 5.3, 5.5, 5.7, 5.8, 6.0, 6.1, 6.2, 6.3, 6.5, 6.7, 6.8 and 6.9. Test H_0\colon \mu = 5.8 against H_a\colon \mu > 5.8 at \alpha = 0.05, finding the p-value both from a t table and with technology.
SolutionThe parameter is \mu, the mean yield of all the cooperative’s plots under the new schedule.
Conditions. The plots were chosen at random. Twelve is far less than 10\% of several hundred plots, so the yields are close enough to independent. With n = 12 the shape of the data has to be checked: the dot plot in Figure 1 shows no outliers and no strong skew.
The twelve yields add to 73.8, so \bar{x} = 73.8/12 = 6.15, and the sample standard deviation is s_x \approx 0.5161. The standard error and the statistic:
The alternative points up, so the p-value is the upper tail (Figure 2). The row for \text{df} = 11 of a t table reads:
| Upper-tail area | 0.05 | 0.025 | 0.01 |
|---|---|---|---|
| t | 1.796 | 2.201 | 2.718 |
Since 2.201 < 2.35 < 2.718, the tail beyond 2.35 is smaller than the tail beyond 2.201 and larger than the tail beyond 2.718: 0.01 < \text{p-value} < 0.025. Technology narrows it: `tcdf(2.349, 10^99, 11)` or `T.DIST.RT(2.349, 11)` gives about 0.019.
Decision: 0.019 \le 0.05, so reject H_0. The table alone was enough to decide, since every value in the bracket is under 0.05. Conclusion in context: if the mean yield under the new schedule were still 5.8 tonnes per hectare, a random sample of 12 plots would average 6.15 or more only about 1.9\% of the time. At the \alpha = 0.05 level there is convincing evidence that the mean yield under the new schedule is above 5.8 tonnes per hectare.
A lower-tailed test from summary numbers
Under the old schedule, a plot drew a long-run mean of 48 cubic meters of water per day. Ketut, who runs the channel gates, suspects the new schedule uses less. For a random sample of 30 plots he records each plot’s mean daily draw over the season: \bar{x} = 45.9 cubic meters, s_x = 5.6 cubic meters, with a dot plot that is mildly skewed and has no outliers. Test at \alpha = 0.05.
SolutionLet \mu be the mean daily water draw of all the cooperative’s plots under the new schedule. Ketut’s suspicion is the alternative:
Conditions: a random sample; 30 plots is under 10\% of the cooperative’s plots; and n = 30 is large enough that mild skew does not matter.
with \text{df} = 29. The t curve is symmetric, so the lower tail below -2.054 equals the upper tail above 2.054. The table row for \text{df} = 29 has 2.045 at tail area 0.025 and 2.462 at 0.01, so 0.01 < \text{p-value} < 0.025. Technology, `tcdf(-10^99, -2.054, 29)`, gives about 0.0245.
Since the p-value is under 0.05, reject H_0. If plots still drew 48 cubic meters a day on average, a sample of 30 averaging 45.9 or less would happen about 2.5\% of the time. There is convincing evidence that the mean daily draw under the new schedule is below 48 cubic meters.
A test that fails to reject
Sekar farms the upper terraces, about 150 plots that the water reaches last, and asks the same question there: is the mean yield above 5.8 tonnes per hectare under the new schedule? A random sample of 8 upper plots gives 5.4, 5.6, 5.7, 6.0, 6.1, 6.2, 6.4 and 6.6 tonnes per hectare, a fairly symmetric spread with no outliers. She has only a t table. Test at \alpha = 0.05.
SolutionLet \mu be the mean yield of all upper-terrace plots under the new schedule; H_0\colon \mu = 5.8, H_a\colon \mu > 5.8.
Conditions: a random sample; 8 is under 10\% of 150, which is 15; and with n = 8 the data must look roughly normal, which they do.
The values add to 48, so \bar{x} = 6.0, and s_x \approx 0.4106.
with \text{df} = 7. In the row for 7 degrees of freedom, 0.896 has upper-tail area 0.20 and 1.415 has 0.10. Since 0.896 < 1.38 < 1.415, the p-value lies between 0.10 and 0.20. (Technology gives about 0.105.) Every value in that bracket is above 0.05, so the table decides it: fail to reject H_0.
Conclusion: at the \alpha = 0.05 level the data do not give convincing evidence that the upper terraces’ mean yield is above 5.8 tonnes per hectare. That is not evidence that the mean is 5.8. A sample mean of 6.0 from 8 plots is quite likely if \mu = 5.8, and also if \mu = 6.0; a sample this small cannot tell those apart. Missing a real increase in this way is a Type II error (Type I and Type II errors).
A two-sided test, and the interval that agrees with it
Under the old schedule, rice took a long-run mean of 120 days from planting to harvest. Wayan asks whether the new schedule changes that, in either direction. A random sample of 16 plots has \bar{x} = 117.6 days and s_x = 4.0 days, with a roughly symmetric dot plot and no outliers. Test at \alpha = 0.05, then build the 95\% t interval and compare.
SolutionLet \mu be the mean days to harvest for all plots under the new schedule. No direction was named in advance, so
Conditions: random, 16 plots well under 10\% of the cooperative’s, and a roughly normal sample.
with \text{df} = 15. A mean as far above 120 would be as much evidence of a change, so both tails count. The row for 15 has 2.131 at one-tail area 0.025 and 2.602 at 0.01, so one tail lies between 0.01 and 0.025 and two tails between 0.02 and 0.05. Technology: 2 \times `tcdf(-10^99, -2.4, 15)` \approx 0.030. Since 0.030 \le 0.05, reject H_0: there is convincing evidence that the mean time to harvest under the new schedule is not 120 days, and the sample points to a shorter time.
The 95\% interval uses t^* = 2.131, the same table value that bounds the two-sided test at 0.05:
The interval leaves out 120, matching the rejection, and it says more: the plausible mean times run from about 115.5 to 119.7 days. The match is no coincidence. Here |t| = 2.40 exceeds t^* = 2.131, and that is the same statement as |117.6 - 120| = 2.4 exceeding the margin 2.131, which is the same as 120 lying outside the interval.
Reading TTest output and a spreadsheet
Ketut checks plant height. At 60 days after planting, plants on the cooperative’s plots have stood a long-run mean of 82 centimeters. He asks whether the mean is different this season. His random sample of 10 plots gives mean heights, in centimeters, of 79.5, 83.0, 78.0, 81.5, 80.0, 84.0, 79.0, 82.5, 77.5 and 80.5 (no outliers, roughly symmetric). A calculator’s TTest, given \mu_0 = 82, the data list and the alternative \mu \neq \mu_0, shows the lines in the table. Read the output, check it against a spreadsheet, and conclude at \alpha = 0.05; then compare the 95\% TInterval, which prints (79.001,\ 82.099).
| Screen line | What it is |
|---|---|
| \mu \neq 82 | the alternative, H_a\colon \mu \neq 82 |
| t = -2.11692 | the test statistic |
| p = .063354 | the two-sided p-value |
| \bar{x} = 80.55 | the sample mean, in centimeters |
| \text{Sx} = 2.166026 | the sample standard deviation s_x |
| n = 10 | the sample size |
Let \mu be the mean height at 60 days of plants on all the cooperative’s plots this season; H_0\colon \mu = 82, H_a\colon \mu \neq 82. The calculator checks no conditions; they hold here as stated (random, 10 plots a small part of the whole, no outliers).
A spreadsheet with the heights in cells A1 to A10 agrees: `=AVERAGE(A1:A10)` gives 80.55 and `=STDEV.S(A1:A10)` about 2.1660. Then \displaystyle \text{SE}_{\bar{x}} = 2.1660/\sqrt{10} \approx 0.6850 and t = (80.55 - 82)/0.6850 \approx -2.117, as on the screen, with \text{df} = 9. The formula `=T.DIST.2T(2.11692, 9)` returns about 0.0634; it takes the size of t, so the sign is dropped.
Decision: 0.0634 > 0.05, so fail to reject H_0. At the \alpha = 0.05 level the data do not give convincing evidence that this season’s mean height at 60 days differs from 82 centimeters.
The interval agrees, as it must: 82 lies inside (79.001,\ 82.099), though only just, which matches a p-value not far above 0.05.
When the normal condition fails
Sekar opens a new terrace and samples 9 of its plots at random, testing H_a\colon \mu > 5.8. The yields are 5.6, 5.7, 5.9, 6.0, 6.0, 6.1, 6.2, 6.3 and 9.6 tonnes per hectare (Figure 3). Should she run the t test?
The sample has n = 9, well under 30, so the t procedure needs data that look roughly normal. The value 9.6 sits far from the other eight, which all lie between 5.6 and 6.3. That is an outlier, and the condition fails.
Running the numbers anyway shows why it matters. With all nine values, \bar{x} \approx 6.378, s_x \approx 1.229, \text{SE}_{\bar{x}} \approx 0.4095, t \approx 1.41 with \text{df} = 8, and the p-value is about 0.098: fail to reject. Without the 9.6, \bar{x} = 5.975, s_x \approx 0.2375, \text{SE}_{\bar{x}} \approx 0.0840, t \approx 2.08 with \text{df} = 7, and the p-value is about 0.038: reject. One plot decides the answer, both through the mean and, more strongly, through s_x, which it inflates fivefold. A t curve is not a good model for the statistic from a sample like this, so neither p-value can be trusted.
Deleting the value to get a cleaner answer is not an honest route. Sekar should first check the record: a yield of 9.6 might be a slip in measuring the plot’s area or weighing its harvest, and a corrected value can be used. If 9.6 is genuine, the new terrace may hold plots unlike the rest, and the honest course is a larger sample, where the shape of the data matters less, or a method that does not lean on normality, which is beyond this lesson.
Boundaries
- The data must come from a random sample or a randomized experiment. Plots chosen because they are easy to reach may differ from the rest, and no calculation corrects that.
- Sampling without replacement needs the sample to be under 10\% of the population.
- With n under 30, the data must show no strong skew and no outliers; with n at least 30, moderate skew is fine, but an extreme outlier still distorts \bar{x} and s_x.
- The test is about the mean. A test on yields says nothing about whether every plot improved, or about the spread of yields.
- The alternative and \alpha are fixed before the data are seen. Choosing a one-sided alternative after seeing which way the data fell halves the p-value without new evidence.
- The exact match between a two-sided test at \alpha and the (1 - \alpha) interval holds for the one-sample t procedures, which share \displaystyle s_x / \sqrt{n}. A one-sided test at \alpha matches one end of the (1 - 2\alpha) interval instead.
- Rejecting H_0 does not say what caused the change. Wayan’s yields were compared with past seasons, not with plots kept on the old schedule this season, so a kinder season could also explain them. Nor does it say the change is large enough to matter (Cautions about significance).
- Failing to reject is never evidence that H_0 is true.
Where this goes next
Measurements made in pairs on the same plot, before and after, reduce to one column of differences and are tested this same way in Paired data: interval and test for a mean difference. Two separate groups, such as plots on the old and the new schedule in the same season, are compared in Test for a difference of means, which is the design that could credit the schedule itself. The slope of a regression line is tested with the same kind of statistic in Test for a slope. Choosing among these is Choosing the right procedure. The general logic sits in Hypothesis testing, and the interval side in Confidence intervals.
Exercises
All data are made up. Find p-values with technology unless a table is asked for; t table rows are given where needed.
Part 1: carrying out a one-sided test
- The cooperative’s rice has a long-run mean of 110 grains per panicle (the head of the plant). Wayan suspects more under the new schedule. A random sample of 25 panicles has \bar{x} = 114.2 and s_x = 9.5, with no outliers. The t table row for \text{df} = 24 has 2.064 at tail area 0.025 and 2.492 at 0.01. Carry out the test at \alpha = 0.05, bracketing the p-value from the table and then finding it with technology.
- The crew has spent a long-run mean of 31 minutes each morning opening and closing the channel gates. Ketut suspects the new schedule takes less time. On 10 randomly chosen mornings the times were 31, 28, 33, 27, 29, 26, 30, 28, 25 and 29 minutes. Test at \alpha = 0.05.
- An upper-tailed test with n = 10 gives t = 1.94. The row for \text{df} = 9 has 1.833 at tail area 0.05 and 2.262 at 0.025. Bracket the p-value, then decide at \alpha = 0.05 and at \alpha = 0.025.
- Would Wayan’s test in Example 1 reject H_0 at \alpha = 0.01? Keeping n = 12 and his standard error, what is the smallest sample mean that would reject at \alpha = 0.05? (For \text{df} = 11, the value with upper tail 0.05 is 1.796.)
- A neighboring cooperative tests H_0\colon \mu = 5.8 against H_a\colon \mu > 5.8 for its mean yield and gets t = 0.52 with \text{df} = 19. Find the p-value, decide at \alpha = 0.05, and conclude in context.
- Ketut writes the hypotheses for Example 1 as H_0\colon \bar{x} = 5.8, H_a\colon \bar{x} = 6.15. Explain what is wrong, and write them correctly.
Part 2: two-sided tests and intervals
- The schedule aims for standing water in the plots with a mean depth of 4.8 centimeters. Sekar measures 20 randomly chosen plots: \bar{x} = 4.62 centimeters, s_x = 0.38 centimeters, no outliers. Test H_a\colon \mu \neq 4.8 at \alpha = 0.05, then build the 95\% interval (t^* = 2.093 for \text{df} = 19) and check that it agrees.
- A 95\% t interval for a mean yield is (5.92,\ 6.38) tonnes per hectare. For each null value, \mu_0 = 5.8, \mu_0 = 6.0 and \mu_0 = 6.4, say whether a two-sided test at \alpha = 0.05 on the same data rejects.
- A 90\% t interval for a mean yield is (6.01,\ 6.29). Which two-sided test does it match? What does it say about a test of H_a\colon \mu > 5.8 at \alpha = 0.05, and why?
Part 2: technology output
- A TTest screen reads \mu > 5.8, t = 2, p = .028470, \bar{x} = 6.06, \text{Sx} = .65, n = 25. State the hypotheses, recompute the standard error and t, give the degrees of freedom, and decide at \alpha = 0.05 and at \alpha = 0.01.
- A two-sided test with n = 20 gives t = 2.05. Write a spreadsheet formula for the p-value, find it, and decide at \alpha = 0.05. What would the p-value be for an upper-tailed alternative?
Part 2: when a condition fails
- Sekar samples 7 plots at random, and the dot plot shows five yields bunched near 5.5 and two near 8, strongly skewed to the right. Can she use the t test? What could she do instead?
- Wayan weighs the harvest of the 15 plots nearest the road, which are easiest to reach. Which condition fails, and does a larger sample of roadside plots fix it?
- Ketut has a random sample of 40 plots whose dot plot is moderately skewed with no extreme outliers. Is the normal condition met, and what are the degrees of freedom?
Reasoning
- Explain why a two-sided t test at \alpha and the (1 - \alpha) t interval always agree, while for a proportion they can disagree.
- Explain why the statistic uses a t distribution instead of the standard normal curve, and why a smaller sample makes the difference larger.
- Explain why Sekar’s conclusion in Example 3 must not be “the upper terraces’ mean yield is 5.8.”
- A large survey of 2{,}500 randomly chosen plots across the island has \bar{x} = 5.83 and s_x = 0.55 tonnes per hectare. Test H_0\colon \mu = 5.8 against H_a\colon \mu > 5.8 at \alpha = 0.05, and comment on whether the result matters to a farmer.
- Explain why the two-sided p-value is twice the one-sided p-value in the direction the data fell.
Answers
- \mu is the mean grains per panicle under the new schedule; H_0\colon \mu = 110, H_a\colon \mu > 110. Random, 25 panicles a tiny part of the crop, no outliers. \displaystyle \text{SE}_{\bar{x}} = 9.5/\sqrt{25} = 1.9; t = 4.2/1.9 \approx 2.21, \text{df} = 24. Since 2.064 < 2.21 < 2.492, 0.01 < \text{p-value} < 0.025; technology gives about 0.018. Reject H_0: convincing evidence the mean exceeds 110 grains per panicle.
- H_0\colon \mu = 31, H_a\colon \mu < 31, with \mu the mean morning gate time under the new schedule. The times run from 25 to 33 with no outliers. \bar{x} = 28.6, s_x \approx 2.366, \text{SE}_{\bar{x}} \approx 0.748, t \approx -3.21, \text{df} = 9, p-value \approx 0.0054. Reject H_0: convincing evidence the mean time is under 31 minutes.
- 1.833 < 1.94 < 2.262, so 0.025 < \text{p-value} < 0.05 (technology: about 0.042). Reject at \alpha = 0.05; fail to reject at \alpha = 0.025.
- No: 0.019 > 0.01. Rejecting at 0.05 needs t \ge 1.796, so \bar{x} \ge 5.8 + 1.796 \times 0.1490 \approx 6.068 tonnes per hectare.
- The p-value is the upper tail beyond 0.52 with 19 degrees of freedom, about 0.30. Since 0.30 > 0.05, fail to reject: no convincing evidence that the neighbor’s mean yield is above 5.8 tonnes per hectare.
- Both name \bar{x}, which is known from the sample and needs no test, and H_a names one value instead of a direction. Correct: H_0\colon \mu = 5.8, H_a\colon \mu > 5.8, with \mu the mean yield of all plots under the new schedule.
- \displaystyle \text{SE}_{\bar{x}} = 0.38/\sqrt{20} \approx 0.0850; t \approx -2.12, \text{df} = 19; p-value \approx 0.048. Reject H_0: convincing evidence the mean depth is not 4.8 centimeters; the sample points lower. Interval: 4.62 \pm 2.093 \times 0.0850 \approx (4.442,\ 4.798), which leaves out 4.8, but only just, as the p-value near 0.05 suggests.
- 5.8 and 6.4 lie outside the interval, so both are rejected; 6.0 lies inside, so it is not.
- A two-sided test at \alpha = 0.10: it rejects exactly the \mu_0 outside the interval. The one-sided test at 0.05 puts all 0.05 in the upper tail, the same tail area beyond the 90\% critical value, so it rejects exactly when \mu_0 is below the lower end. Since 5.8 < 6.01, it rejects.
- H_0\colon \mu = 5.8, H_a\colon \mu > 5.8. \displaystyle \text{SE}_{\bar{x}} = 0.65/\sqrt{25} = 0.13, t = 0.26/0.13 = 2.0, \text{df} = 24. Reject at 0.05 since 0.0285 \le 0.05; fail to reject at 0.01.
- `=T.DIST.2T(2.05, 19)` gives about 0.0544. Since 0.0544 > 0.05, fail to reject. Upper-tailed, `=T.DIST.RT(2.05, 19)` gives about 0.0272, which would reject, had that side been chosen before sampling.
- No: with n = 7 the data must look roughly normal, and strong skew breaks that. She can check the two high records for errors and take a larger random sample.
- The random condition fails: roadside plots may differ from the rest. A larger roadside sample only measures the wrong group more precisely.
- Yes: n = 40 is at least 30, so moderate skew is fine. \text{df} = 39.
- Both use the same standard error \displaystyle s_x/\sqrt{n} and the same t curve, so |t| \ge t^* is the same inequality as |\bar{x} - \mu_0| \ge the margin of error. For a proportion the test uses \displaystyle \sqrt{p_0(1-p_0)/n} and the interval uses \displaystyle \sqrt{\hat{p}(1-\hat{p})/n}; the two measuring sticks differ, so near the boundary the answers can differ.
- The spread \sigma is unknown and s_x estimates it. A small s_x by chance makes t large, so extreme values of t are more common than extreme z values: heavier tails. A small sample estimates \sigma less reliably, so its tails are heavier still; as n grows, t approaches the normal curve.
- Failing to reject says only that the data are consistent with \mu = 5.8. They are also consistent with \mu = 6.0 and other values above 5.8; the test gives no evidence for H_0.
- \displaystyle \text{SE}_{\bar{x}} = 0.55/\sqrt{2500} = 0.011; t = 0.03/0.011 \approx 2.73; p-value \approx 0.0032. Reject H_0: convincing evidence the island’s mean is above 5.8. But 0.03 tonnes per hectare is about half a percent of the yield, likely too small to matter; a very large sample detects very small differences.
- A two-sided alternative counts results as far from \mu_0 on either side. The t curve is symmetric about 0, so the tail beyond -|t| equals the tail beyond |t|, and together they are twice one tail.