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

Testing a Proportion (Left-Tailed)

A left-tailed test looks for evidence that the true proportion is smaller than a reference value p₀. The steps are the same as in the right-tailed test; only the alternative hypothesis and the tail of the p-value change.

The scenario

Industry data says that 20% of smartphones suffer a cracked screen within the first year. A company making protective cases wants evidence that its case lowers this rate. It follows 350 randomly chosen customers for a year: 52 of them cracked their screen.

Step 1: Hypotheses

text
H₀: p = 0.20     (the case makes no difference)
H₁: p < 0.20     (fewer cracked screens)   ← left-tailed

Step 2: Significance level

Because the company wants to put the claim in advertising, it uses a stricter α = 0.01.

Step 3: Conditions

python · try it yourself
n, p0 = 350, 0.20
print("n*p0 =", n * p0, " n*(1-p0) =", n * (1 - p0))
n*p0 = 70.0  n*(1-p0) = 280.0

Both expected counts are well above 5, and the customers were randomly selected, so the z-test is appropriate.

Step 4: Test statistic

text
z = (p̂ − p₀) / √(p₀(1 − p₀) / n)
python · try it yourself
import math

x, n, p0 = 52, 350, 0.20
p_hat = x / n
z = (p_hat - p0) / math.sqrt(p0 * (1 - p0) / n)
print(f"p-hat = {p_hat:.4f}")
print(f"z = {z:.3f}")
p-hat = 0.1486
z = -2.405

The z-score is negative because p̂ is below p₀. In a left-tailed test, that is the direction that counts as evidence for H₁.

Step 5: p-value

For a left-tailed test the p-value is the area to the left of z: P(Z ≤ z). The critical value is negative too:

python · try it yourself
from scipy import stats

z = -2.405
alpha = 0.01
p_value = stats.norm.cdf(z)
z_crit = stats.norm.ppf(alpha)

print(f"p-value = {p_value:.4f}")
print(f"critical value = {z_crit:.3f}  -> reject if z < {z_crit:.3f}")
p-value = 0.0081
critical value = -2.326  -> reject if z < -2.326
python · try it yourself
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

z_obs, z_crit = -2.405, stats.norm.ppf(0.01)
x = np.linspace(-4, 4, 400)
fig, ax = plt.subplots(figsize=(6.5, 3))
ax.plot(x, stats.norm.pdf(x), color="#2a78d6", linewidth=2)
tail = x <= z_crit
ax.fill_between(x[tail], stats.norm.pdf(x[tail]), color="#eb6834", alpha=0.5, label="rejection region (1%)")
ax.axvline(z_obs, color="#0b0b0b", linestyle="--", label=f"observed z = {z_obs:.2f}")
ax.legend(frameon=False, loc="upper right")
ax.set_yticks([])
plt.tight_layout()
plt.show()
print(f"observed z = {z_obs} vs critical value {z_crit:.3f}")
observed z = -2.405 vs critical value -2.326

Step 6: Conclusion

The p-value is about 0.008, which is below α = 0.01, and z = −2.405 lies beyond the critical value of −2.326. We reject H₀.

In context: at the 1% significance level, there is evidence that fewer than 20% of phones protected by the case crack their screen within a year.

Note how close the call was: at α = 0.01, a few more cracked screens in the sample would have changed the decision. Let's see how the p-value depends on the count:

python · try it yourself
import math
from scipy import stats

n, p0 = 350, 0.20
for x in [50, 52, 54, 56, 60]:
    z = (x / n - p0) / math.sqrt(p0 * (1 - p0) / n)
    p = stats.norm.cdf(z)
    verdict = "reject" if p <= 0.01 else "fail to reject"
    print(f"x={x}: p-hat={x / n:.3f}, z={z:6.3f}, p={p:.4f} -> {verdict} at 1%")
x=50: p-hat=0.143, z=-2.673, p=0.0038 -> reject at 1%
x=52: p-hat=0.149, z=-2.405, p=0.0081 -> reject at 1%
x=54: p-hat=0.154, z=-2.138, p=0.0163 -> fail to reject at 1%
x=56: p-hat=0.160, z=-1.871, p=0.0307 -> fail to reject at 1%
x=60: p-hat=0.171, z=-1.336, p=0.0907 -> fail to reject at 1%

With statsmodels and an exact test

python · try it yourself
from scipy import stats
from statsmodels.stats.proportion import proportions_ztest

z, p = proportions_ztest(52, 350, value=0.20, alternative="smaller", prop_var=0.20)
print(f"z-test     : z = {z:.3f}, p = {p:.4f}")

exact = stats.binomtest(52, 350, p=0.20, alternative="less")
print(f"exact test : p = {exact.pvalue:.4f}")
z-test     : z = -2.405, p = 0.0081
exact test : p = 0.0080

In statsmodels the left-tailed alternative is called "smaller"; in SciPy it is "less". Both tests agree.

Note: A significant result says the case-protected rate is below 20%. It does not prove the case caused the drop: careful customers may be more likely to buy cases in the first place. Only a randomised experiment could separate those explanations (see Study Types).

Test yourself

Which alternative hypothesis makes a test left-tailed?

  1. H₁: p ≠ 0.3
  2. H₁: p > 0.3
  3. H₁: p < 0.3
  4. H₁: p = 0.3

For a left-tailed z-test at α = 0.05, what is the critical value?

  1. 1.645
  2. −1.645
  3. −1.96
  4. 1.96

A left-tailed test gives z = +1.2. What can you say without any calculation?

  1. Reject H₀
  2. The p-value is greater than 0.5, so you can't reject H₀
  3. The p-value is 0.12
  4. The test is invalid