TExcelTAD
Home › Statistics › Testing a Mean (Left-Tailed)

Testing a Mean (Left-Tailed)

A left-tailed t-test looks for evidence that the true mean is less than μ₀. Typical questions: "Are packages under-filled?", "Did the new process reduce waiting times?", "Is the drug lowering blood pressure below the target?"

The scenario

Cereal boxes are labelled 500 g. A consumer organisation suspects the producer systematically under-fills them. It buys 20 boxes from different shops and weighs the contents (grams):

python · try it yourself
import numpy as np

boxes = np.array([497.8, 501.2, 495.6, 498.9, 499.4, 496.1, 500.3, 497.2, 498.5, 494.9,
                  499.8, 497.5, 498.1, 496.8, 500.6, 497.9, 499.1, 495.8, 498.7, 497.4])

print(f"n = {boxes.size}")
print(f"mean = {boxes.mean():.2f} g, sd = {boxes.std(ddof=1):.3f} g")
print(f"boxes below 500 g: {(boxes < 500).sum()} of {boxes.size}")
n = 20
mean = 498.08 g, sd = 1.727 g
boxes below 500 g: 17 of 20

The sample mean is below 500 g, but is the gap larger than random variation would explain?

Step 1–3: Hypotheses, α, conditions

text
H₀: μ = 500 g
H₁: μ < 500 g      ← left-tailed
α = 0.05

The boxes were bought in different shops (a reasonable stand-in for a random sample), and fill weights from a machine are typically close to normal. A quick look at the data confirms there is no strong skew or outlier:

python · try it yourself
import numpy as np
from scipy import stats

boxes = np.array([497.8, 501.2, 495.6, 498.9, 499.4, 496.1, 500.3, 497.2, 498.5, 494.9,
                  499.8, 497.5, 498.1, 496.8, 500.6, 497.9, 499.1, 495.8, 498.7, 497.4])
print(f"skewness = {stats.skew(boxes):.3f}")
print(f"min = {boxes.min()}, max = {boxes.max()}, median = {np.median(boxes)}")
skewness = -0.039
min = 494.9, max = 501.2, median = 498.0

Step 4–5: Test statistic and p-value

The statistic is computed exactly as in the right-tailed test. The p-value is now the area to the left of t:

python · try it yourself
import math
import numpy as np
from scipy import stats

boxes = np.array([497.8, 501.2, 495.6, 498.9, 499.4, 496.1, 500.3, 497.2, 498.5, 494.9,
                  499.8, 497.5, 498.1, 496.8, 500.6, 497.9, 499.1, 495.8, 498.7, 497.4])
n, xbar, s = boxes.size, boxes.mean(), boxes.std(ddof=1)

t = (xbar - 500) / (s / math.sqrt(n))
p_value = stats.t.cdf(t, df=n - 1)          # area to the left
t_crit = stats.t.ppf(0.05, df=n - 1)        # negative critical value

print(f"t = {t:.3f}, df = {n - 1}")
print(f"p-value = {p_value:.6f}")
print(f"critical value = {t_crit:.3f}  -> reject if t < {t_crit:.3f}")
t = -4.971, df = 19
p-value = 0.000042
critical value = -1.729  -> reject if t < -1.729

Step 6: Conclusion

t ≈ −4.97 is far below the critical value −1.729, and the p-value is about 0.00004. We reject H₀.

In context: there is strong evidence that the mean content of the boxes is less than the labelled 500 g.

With SciPy in one line:

python · try it yourself
import numpy as np
from scipy import stats

boxes = np.array([497.8, 501.2, 495.6, 498.9, 499.4, 496.1, 500.3, 497.2, 498.5, 494.9,
                  499.8, 497.5, 498.1, 496.8, 500.6, 497.9, 499.1, 495.8, 498.7, 497.4])
res = stats.ttest_1samp(boxes, popmean=500, alternative="less")
print(f"t = {res.statistic:.3f}, p = {res.pvalue:.6f}")
print(f"one-sided 95% upper bound for μ: {res.confidence_interval(0.95).high:.2f} g")
t = -4.971, p = 0.000042
one-sided 95% upper bound for μ: 498.75 g

With 95% confidence, the true mean fill is at most about 498.8 g, at least 1.2 g short per box.

Statistical vs. practical significance

Is 2 g out of 500 g a big deal? That depends on the rules. Many countries' packaging rules care about the average not being below the label and about how many packs are far below it. A t-test answers only the first question. A complementary check could estimate how many boxes fall below some tolerance limit, such as 495.5 g:

python · try it yourself
import numpy as np
from scipy import stats

boxes = np.array([497.8, 501.2, 495.6, 498.9, 499.4, 496.1, 500.3, 497.2, 498.5, 494.9,
                  499.8, 497.5, 498.1, 496.8, 500.6, 497.9, 499.1, 495.8, 498.7, 497.4])
fill = stats.norm(boxes.mean(), boxes.std(ddof=1))      # fitted normal model of the filling
print(f"estimated share of boxes below 495.5 g: {fill.cdf(495.5):.1%}")
estimated share of boxes below 495.5 g: 6.8%

A simulation of the test's error rate

What if the producer were honest (true mean exactly 500 g)? Then a left-tailed test at α = 0.05 should cry "under-filled" only 5% of the time:

python · try it yourself
import numpy as np
from scipy import stats

rng = np.random.default_rng(500)
samples = rng.normal(500, 1.7, size=(20_000, 20))     # 20,000 honest studies of 20 boxes
p = stats.ttest_1samp(samples, popmean=500, axis=1, alternative="less").pvalue
print(f"honest producer wrongly accused: {np.mean(p <= 0.05):.2%}")
honest producer wrongly accused: 5.05%

Exactly as designed, about 5% of honest producers would be wrongly accused. That is the Type I error rate the consumer organisation accepted when choosing α = 0.05.

Test yourself

In a left-tailed t-test with t = −2.1 and df = 12, which code gives the p-value?

  1. stats.t.sf(-2.1, 12)
  2. stats.t.cdf(-2.1, 12)
  3. 2 * stats.t.sf(2.1, 12)
  4. stats.norm.cdf(-2.1)

What is the left-tailed critical value for α = 0.05 and df = 19?

  1. 1.729
  2. −1.729
  3. −2.093
  4. −1.645

A left-tailed test of H₀: μ = 500 gives p = 0.003. Which statement is correct?

  1. The probability that the boxes are full is 0.3%
  2. If the true mean were 500 g, a sample mean this low would occur only about 0.3% of the time
  3. 99.7% of boxes are under-filled
  4. The mean is 0.3% below 500 g