Probability & Statistics · Unit 2 · Topic 09

Testing of hypothesis: real difference, or luck of the sample?

Short answer

Assume the null hypothesis \(H_0\), compute a test statistic such as \(z = \dfrac{\bar x - \mu}{\sigma/\sqrt n}\), and compare it with the critical value. If it is larger, reject \(H_0\).

Example: \(n = 64\), \(\bar x = 52\), \(\mu = 50\), \(\sigma = 8\) gives \(z = 2 > 1.96\), so reject \(H_0\) at 5%. For small samples use \(t\) with \(n - 1\) degrees of freedom.

Engineering MathsBScStatistics
01

The logic of a test

Before you start: you need the normal distribution and the standard normal variable \(Z\).

A company says its packets hold 50 g on average. You weigh 10 packets and get a mean of 49 g. Is the company wrong, or is a 1 g shortfall just the luck of the sample? A test of hypothesis turns this into a yes-or-no decision with a known risk of being wrong.

The vocabulary

Null hypothesis \(H_0\): the claim of "no difference", for example \(\mu = 50\). We assume it is true and look for evidence against it.

Alternative hypothesis \(H_1\): what we accept if \(H_0\) is rejected: \(\mu \ne 50\) (two-tailed), or \(\mu < 50\) or \(\mu > 50\) (one-tailed).

Level of significance \(\alpha\): the risk we accept of rejecting a true \(H_0\) (a Type I error). Usually 5% or 1%.

Critical region: the values of the test statistic for which we reject \(H_0\). Its boundary is the critical value.

A Type II error is the opposite mistake: accepting \(H_0\) when it is false. When we "accept \(H_0\)" we only mean the sample gives no strong evidence against it. It is not proof that \(H_0\) is true.

The five steps of every test

  1. State \(H_0\) and \(H_1\), and decide whether the test is one-tailed or two-tailed.
  2. Choose \(\alpha\) (5% unless told otherwise).
  3. Compute the test statistic (\(z\) or \(t\)) from the sample.
  4. Find the critical value from the table, with degrees of freedom for \(t\).
  5. Decide: if \(|z|\) or \(|t|\) is bigger than the critical value (on the side \(H_1\) points to), reject \(H_0\); otherwise accept it.

Critical values of z

LevelTwo-tailedOne-tailed
5%1.961.645
1%2.582.33

For a two-tailed test at 5%, 2.5% sits in each tail, which is why the value is 1.96 and not 1.645.

02

Large samples: the z-test

When the sample is large (\(n \ge 30\) is the usual rule), the sample mean is very nearly normal, and the sample standard deviation \(s\) can stand in for \(\sigma\) if \(\sigma\) is unknown.

Test for one mean

\[z = \frac{\bar x - \mu}{\sigma/\sqrt n}\]

Test for the difference of two means

\[z = \frac{\bar x_1 - \bar x_2}{\sqrt{\dfrac{\sigma_1^2}{n_1} + \dfrac{\sigma_2^2}{n_2}}}\]

The denominator is the standard error: how much the statistic would vary from sample to sample. So \(z\) counts how many standard errors the sample result is from what \(H_0\) predicts.

03

Small samples: the t-test

With a small sample (\(n < 30\)) and unknown \(\sigma\), replacing \(\sigma\) by \(s\) adds extra uncertainty. The statistic then follows Student's \(t\)-distribution, which has fatter tails than the normal, so the critical values are larger. The shape depends on the degrees of freedom (df).

t-test for one mean

\[t = \frac{\bar x - \mu}{s/\sqrt n}, \qquad s^2 = \frac{\sum (x - \bar x)^2}{n - 1}, \qquad \text{df} = n - 1\]

t-test for two means

\[t = \frac{\bar x_1 - \bar x_2}{S\sqrt{\dfrac{1}{n_1} + \dfrac{1}{n_2}}}, \qquad S^2 = \frac{\sum (x_1 - \bar x_1)^2 + \sum (x_2 - \bar x_2)^2}{n_1 + n_2 - 2}\]

df \(= n_1 + n_2 - 2\). This assumes the two populations are normal with equal variances.

Some books define \(s\) with \(n\) in the denominator and then write \(t = \dfrac{\bar x - \mu}{s/\sqrt{n - 1}}\). It is the same number, just organised differently. Use one convention and stick to it.

df5% two-tailed5% one-tailed1% two-tailed
52.5712.0154.032
92.2621.8333.250
112.2011.7963.106
162.1201.7462.921
242.0641.7112.797
04

Solved examples

Example 1: z-test for one mean

Easy

A sample of 64 students has mean mark 52. Can it come from a population with mean 50 and standard deviation 8? Test at 5% and at 1%.

  1. \(H_0: \mu = 50\), \(H_1: \mu \ne 50\) (two-tailed).
  2. \(z = \dfrac{52 - 50}{8/\sqrt{64}} = \dfrac{2}{1} = 2\).
  3. At 5%: \(2 > 1.96\), so reject \(H_0\). At 1%: \(2 < 2.58\), so accept \(H_0\).

AnswerSignificant at 5%, not significant at 1%

Example 2: A one-tailed z-test

Medium

A maker claims bulbs last at least 1000 hours on average. A sample of 100 bulbs has mean 980 hours and standard deviation 80 hours. Test the claim at 5%.

  1. \(H_0: \mu = 1000\), \(H_1: \mu < 1000\) (left-tailed, because only a shortfall goes against the claim).
  2. Standard error \(= \dfrac{80}{\sqrt{100}} = 8\). \(z = \dfrac{980 - 1000}{8} = -2.5\).
  3. Critical value for a left tail at 5%: \(-1.645\). Since \(-2.5 < -1.645\), reject \(H_0\).

AnswerReject the claim: the bulbs last less than 1000 hours on average

Example 3: Difference of two means

Medium

Sample A: \(n_1 = 100\), mean 68, s.d. 5. Sample B: \(n_2 = 150\), mean 66.5, s.d. 6. Is the difference in means significant at 5%?

  1. \(H_0: \mu_1 = \mu_2\), \(H_1: \mu_1 \ne \mu_2\).
  2. \(\dfrac{s_1^2}{n_1} + \dfrac{s_2^2}{n_2} = \dfrac{25}{100} + \dfrac{36}{150} = 0.25 + 0.24 = 0.49\), so the standard error is 0.7.
  3. \(z = \dfrac{68 - 66.5}{0.7} = \dfrac{1.5}{0.7} \approx 2.14\). Since \(2.14 > 1.96\), reject \(H_0\).

AnswerThe difference is significant at 5%

Example 4: t-test from raw data

Medium

Ten packets weigh (in g): 49, 51, 48, 50, 47, 52, 49, 48, 50, 46. Test at 5% whether the mean weight is 50 g.

  1. \(H_0: \mu = 50\), \(H_1: \mu \ne 50\). \(\bar x = \dfrac{490}{10} = 49\).
  2. Deviations from 49: 0, 2, \(-1\), 1, \(-2\), 3, 0, \(-1\), 1, \(-3\). \(\sum (x - \bar x)^2 = 30\), so \(s^2 = \dfrac{30}{9} = 3.333\) and \(s = 1.826\).
  3. \(t = \dfrac{49 - 50}{1.826/\sqrt{10}} = \dfrac{-1}{0.5774} = -1.732\).
  4. df \(= 9\); the 5% two-tailed value is 2.262. Since \(1.732 < 2.262\), accept \(H_0\).

AnswerNo evidence that the mean differs from 50 g

Example 5: t-test from summary figures

Exam level

A sample of 12 has mean 27.5 and standard deviation \(s = 3\) (divisor \(n - 1\)). Test at 5% and 1% whether the population mean is 25.

  1. \(H_0: \mu = 25\), \(H_1: \mu \ne 25\).
  2. \(t = \dfrac{27.5 - 25}{3/\sqrt{12}} = \dfrac{2.5}{0.8660} \approx 2.887\), with df \(= 11\).
  3. At 5%: \(2.887 > 2.201\), reject \(H_0\). At 1%: \(2.887 < 3.106\), accept \(H_0\).

AnswerSignificant at 5% but not at 1%

Example 6: A one-tailed t-test

Medium

A coaching class claims its students' mean score is above 60. A sample of 10 students has mean 63 and \(s = 4\). Test at 5%.

  1. \(H_0: \mu = 60\), \(H_1: \mu > 60\) (right-tailed).
  2. \(t = \dfrac{63 - 60}{4/\sqrt{10}} = \dfrac{3}{1.265} \approx 2.372\), df \(= 9\).
  3. 5% one-tailed value for df 9 is 1.833. Since \(2.372 > 1.833\), reject \(H_0\).

AnswerThe data support the claim that the mean is above 60

Example 7: Two-sample t-test

Exam level

Group A scores: 12, 15, 14, 13, 16. Group B scores: 17, 16, 18, 15, 19, 17. Do the group means differ significantly at 5%?

  1. \(\bar x_1 = 14\), \(\sum (x_1 - \bar x_1)^2 = 4 + 1 + 0 + 1 + 4 = 10\). \(\bar x_2 = 17\), \(\sum (x_2 - \bar x_2)^2 = 0 + 1 + 1 + 4 + 4 + 0 = 10\).
  2. \(S^2 = \dfrac{10 + 10}{5 + 6 - 2} = \dfrac{20}{9} = 2.222\), so \(S = 1.491\).
  3. \(\sqrt{\tfrac{1}{5} + \tfrac{1}{6}} = \sqrt{\tfrac{11}{30}} = 0.6055\). \(t = \dfrac{14 - 17}{1.491 \times 0.6055} = \dfrac{-3}{0.9027} \approx -3.32\).
  4. df \(= 9\), critical value 2.262. Since \(3.32 > 2.262\), reject \(H_0\).

AnswerThe means differ significantly at 5%

Vipul Sir's tip

Write \(H_1\) before you touch a single number. The word in the question decides the tail: "differs" means two-tailed, "at least", "more than" or "less than" means one-tailed. Once \(H_1\) is on paper, choosing between 1.96 and 1.645 is automatic.

05

Common mistakes

1. Using the one-tailed value for a two-tailed test

"Is the mean different from 50?" at 5% needs 1.96, not 1.645. With \(z = 1.8\), the wrong value would make you reject \(H_0\) when you should accept it.

2. Forgetting \(\sqrt n\) in the standard error

In Example 1, \(\dfrac{52 - 50}{8} = 0.25\) is wrong. The standard error is \(\dfrac{\sigma}{\sqrt n} = \dfrac{8}{8} = 1\), giving \(z = 2\).

3. Using the z table for a small sample

For \(n = 10\) with \(\sigma\) unknown, the 5% two-tailed critical value is \(t = 2.262\) (df 9), not 1.96. A statistic of 2.1 is significant by one and not by the other.

06

Practice questions

Try each one on paper before you open the answer.

Q1A sample of 36 has mean 48. The population is claimed to have mean 50 and \(\sigma = 6\). Test at 5% and 1%.

\(z = \dfrac{48 - 50}{6/6} = -2\). At 5%: \(2 > 1.96\), reject. At 1%: \(2 < 2.58\), accept.

Q2A sample of 49 has mean 51.5 and \(s = 7\). Test \(H_0: \mu = 50\) against \(H_1: \mu > 50\) at 5%.

\(z = \dfrac{1.5}{7/7} = 1.5 < 1.645\). Accept \(H_0\).

Q3Sample 1: \(n = 50\), mean 85, s.d. 6. Sample 2: \(n = 80\), mean 82, s.d. 8. Test the difference at 5% and 1%.

Standard error \(= \sqrt{0.72 + 0.8} = \sqrt{1.52} = 1.233\). \(z = \dfrac{3}{1.233} \approx 2.43\).

Reject at 5% (\(2.43 > 1.96\)); accept at 1% (\(2.43 < 2.58\)).

Q4Data: 10, 12, 9, 11, 13, 11. Test at 5% whether the population mean is 10.

\(\bar x = 11\), \(\sum (x - \bar x)^2 = 10\), \(s^2 = 2\), \(s = 1.414\).

\(t = \dfrac{1}{1.414/\sqrt 6} = 1.732\). df 5, critical value 2.571. Accept \(H_0\).

Q5A sample of 25 has mean 52 and \(s = 5\). Test \(H_0: \mu = 50\) at 5% (two-tailed).

\(t = \dfrac{2}{5/5} = 2.0\). df 24, critical value 2.064. Since \(2.0 < 2.064\), accept \(H_0\).

Q6Sample 1: \(n_1 = 8\), mean 20, \(s_1 = 3\). Sample 2: \(n_2 = 10\), mean 17, \(s_2 = 3\) (both with divisor \(n - 1\)). Test the difference at 5%.

\(S^2 = \dfrac{7(9) + 9(9)}{16} = 9\), so \(S = 3\).

\(t = \dfrac{3}{3\sqrt{0.125 + 0.1}} = \dfrac{1}{0.4743} \approx 2.108\). df 16, critical value 2.120. Just below, so accept \(H_0\).

Stuck on a question?

Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.

07

Frequently asked questions

What is a null hypothesis?

The statement of "no effect" or "no difference" that the test assumes and tries to find evidence against, such as \(\mu = 50\) or \(\mu_1 = \mu_2\).

What does a 5% level of significance mean?

If \(H_0\) is true, there is a 5% chance that the sample will still fall in the critical region and we wrongly reject it. It is the risk of a Type I error that we agree to accept.

When should I use a t-test instead of a z-test?

Use \(t\) when the sample is small (\(n < 30\)) and the population standard deviation is unknown. For large samples the two give almost the same critical values, so \(z\) is used.

What is the difference between one-tailed and two-tailed tests?

A two-tailed test looks for a difference in either direction (\(\mu \ne \mu_0\)) and splits \(\alpha\) between both tails. A one-tailed test looks in one direction only (\(\mu > \mu_0\) or \(\mu < \mu_0\)) and puts all of \(\alpha\) in that tail.

Related lessons

← All 10 Probability & Statistics topics
Vipul Sir
Written by Vipul Sir

Vipul Sir has taught mathematics for over 15 years to HSC, CBSE, ICSE, IGCSE/IB, Diploma, Engineering and BSc students at VVS Classes in Goregaon and Vile Parle, Mumbai. He teaches every class himself, concepts first and exam technique second.

Probability and Statistics

Get Probability & Statistics right, with Vipul Sir beside you.

Concept-first classes in small batches in Goregaon and Vile Parle, or online. Your first class is free.

WhatsApp↗