The most common questions are whether a mean or a proportion differs from a stated value. The z test is used when the sample is large or sigma is known, and the t test when the sample is small and sigma is unknown.

Z Test for a Mean

For a large sample, or a normal population with known sigma, the test statistic is z = (x-bar - mu0) / (sigma / square root of n), where mu0 is the value in H0. If the sample standard deviation s is used for a large sample, the same formula is applied with s in place of sigma. At alpha = 0.05 the critical value is 1.96 for a two-tailed test and 1.645 for a one-tailed test. H0 is rejected when the absolute value of z is greater than the critical value.

T Test for a Mean

When the sample is small, n below 30, the population is normal and sigma is unknown, we use t = (x-bar - mu0) / (s / square root of n), with n - 1 degrees of freedom. The t distribution is symmetric like the normal but has heavier tails. The critical value is read from the t table and is larger than the z value, which allows for the extra uncertainty. As n increases, t approaches z.

Definition: Test of a mean. A test that compares the sample mean with a hypothesised population mean using a z or t statistic.

Z Test for a Proportion

To test H0: P = P0 for a large sample, the statistic is z = (p - P0) / square root of (P0 (1 - P0) / n), where p is the sample proportion. The decision rule is the same as for the mean.

Table 4.3: Choosing the test

Situation Test Statistic
Mean, large n or sigma known z (x-bar - mu0) / (sigma / sqrt n)
Mean, small n, sigma unknown t (x-bar - mu0) / (s / sqrt n), n - 1 df
Proportion, large n z (p - P0) / sqrt(P0 (1 - P0) / n)

Example 4.3: Z test for a mean

Problem: A bulb is claimed to last 1000 hours on average. A sample of 49 bulbs has mean 980 hours, and sigma is 70 hours. Test at 5 percent level whether the mean is less than 1000.

Solution:

  1. H0: mu = 1000, H1: mu less than 1000 (left-tailed).
  2. z = (980 - 1000) / (70 / 7) = -20 / 10 = -2.
  3. The critical value is -1.645 and -2 is less than -1.645.

Result: H0 is rejected. The sample supports the view that the mean life is less than 1000 hours.

Example 4.4: T test for a mean

Problem: Ten students have mean marks 54 with standard deviation 6. Test at 5 percent whether the population mean differs from 50.

Solution:

  1. H0: mu = 50, H1: mu is not equal to 50 (two-tailed), df = 9.
  2. t = (54 - 50) / (6 / square root of 10) = 4 / 1.897 = 2.108.
  3. The critical value for 9 df at 5 percent two-tailed is 2.262, and 2.108 is less than 2.262.

Result: H0 is not rejected. The data do not show that the mean differs from 50.

Example 4.5: Z test for a proportion

Problem: A firm claims that 90 percent of its parts are good. In a sample of 200, 174 are good. Test at 5 percent whether the proportion differs from 0.9.

Solution:

  1. p = 174 / 200 = 0.87, and H0: P = 0.9, H1: P is not equal to 0.9.
  2. Standard error = square root of (0.9 × 0.1 / 200) = 0.0212.
  3. z = (0.87 - 0.90) / 0.0212 = -1.414.

Result: The absolute value 1.414 is less than 1.96, so H0 is not rejected.

from math import sqrt
print(round((980 - 1000) / (70 / sqrt(49)), 3))
print(round((54 - 50) / (6 / sqrt(10)), 3))
print(round((0.87 - 0.9) / sqrt(0.9 * 0.1 / 200), 3))

Output

-2.0
2.108
-1.414

Common mistakes

  • Using the z test for a small sample with an unknown sigma.
  • Using n instead of n - 1 for the degrees of freedom of the t test.
  • Stating a conclusion without relating it to the original claim.

Key takeaways

  • z = (x-bar - mu0) / (sigma / sqrt n) for a mean.
  • t uses s and n - 1 degrees of freedom.
  • For a proportion, z = (p - P0) / sqrt(P0 (1 - P0) / n).
  • Critical values at 5 percent: 1.96 two-tailed, 1.645 one-tailed.

Practice questions

  1. When is a t test used instead of a z test?
  2. How many degrees of freedom has the one-sample t test?
  3. What is the two-tailed critical z value at 5 percent?

Answers to the practice questions

  1. When the sample is small and sigma is unknown.
  2. n - 1.
  3. 1.96.

Sources

  • Official BCA syllabus Probability and Statistics, course code 26BCA403DS01, Unit IV