2 Testing Of Hypothesis

Statistics II · Unit 2 · 8 hrs

Testing of hypothesis

Exam-focused notes for Testing of hypothesis (Statistics II, STA215): what the TU syllabus asks and how it has actually been tested, with 12 solved past questions from this unit.

Testing of hypothesis in short

Hypothesis testing turns a claim about a population parameter into a formal decision procedure: state two competing hypotheses, compute a test statistic from a sample, and decide which hypothesis the evidence supports.

Testing of hypothesis: notes

Types of statistical hypotheses

A hypothesis is an assumption or claim about a population parameter that can be tested using sample data. The null hypothesis, denoted $H_0$, is the hypothesis of no effect or no difference, always stated with an equality sign, for example $H_0: \mu = 30$. The alternative hypothesis, denoted $H_1$, is the claim accepted if the null hypothesis is rejected, and it takes one of three forms depending on the question asked: $H_1: \mu \neq 30$ gives a two-tailed test (the population mean is simply different from 30), while $H_1: \mu > 30$ or $H_1: \mu < 30$ each give a one-tailed test (right-tailed or left-tailed respectively), used when the question specifies a direction of difference.

Power of the test, concept of p-value and use of p-value in decision making

Two kinds of error are possible in a test. A Type I error is rejecting $H_0$ when it is actually true, with probability $\alpha$, the chosen level of significance; a Type II error is accepting $H_0$ when it is actually false, with probability $\beta$. The power of the test, $1-\beta$, is the probability of correctly rejecting a false null hypothesis, and it increases as the sample size grows, as the true effect size grows, or as $\alpha$ is relaxed. The p-value is the probability, assuming $H_0$ is true, of obtaining a test statistic at least as extreme as the one actually observed; it is compared directly against $\alpha$ to reach a decision, rejecting $H_0$ if the p-value is less than $\alpha$ and accepting it otherwise. This gives exactly the same decision as comparing the calculated statistic with the tabulated critical value, but it also reports how strong the evidence is.

Worked example. A company claims its average server response time is 100 ms. After a configuration change, a sample of $n=49$ requests gives $\bar{x}=97$ ms, with population standard deviation known from long history to be $\sigma=14$ ms. Testing $H_0: \mu = 100$ against the one-tailed $H_1: \mu < 100$ at $\alpha=0.05$: $$Z_{cal} = \frac{\bar{x}-\mu}{\sigma/\sqrt{n}} = \frac{97-100}{14/\sqrt{49}} = -1.5$$ $$p\text{-value} = P(Z < -1.5) = 0.0668$$ Since the p-value $(0.0668)$ exceeds $\alpha = 0.05$, $H_0$ is not rejected: the sample does not give strong enough evidence that the true mean response time has actually dropped below 100 ms.

What this unit covers

  • Types of statistical hypotheses
  • Power of the test, concept of p-value and use of p-value in decision making
  • steps used in testing of hypothesis
  • one sample tests for mean of normal population (for known and unknown variance)
  • test for single proportion
  • test for difference between two means and two proportions
  • paired sample t-test
  • Linkage between confidence interval and testing of hypothesis
  • Problems and illustrative examples related to computer Science and IT

paired sample t-test

2081 · 10 marks

T-Test for Difference Between Two Sample Means

Paired measurements of gripping strength for 8 left-handed writers: Person 1 2 3 4 5 6 7 8 -------------------------------- Left (L) 112 131 142 90 125 130 95 90 Right (R) 104 136 135 86 132 120 86 85 - $n = 8$ - $\alpha = 0.05$ - Claim: left hand strength right hand strength (one-tailed test) --...

Open this answer on its own page →

2079 · 10 marks

Hypothesis Testing: Type I and Type II Errors

Define Type I and Type II error in testing of hypothesis. A psychologist wishes to verify that a certain drug increases the reaction time to given stimulus. The following reaction times (in tenth of seconds) were recorded before and after injection of the drug for each of four subjects. Test at 5% level of significance to determine whether the drug significantly increases the reaction time.

Reaction TimeSubject 1Subject 2Subject 3Subject 4
Before721212
After1331813

[10]

Type I Error (α): Rejecting a null hypothesis $H0$ when it is actually true. Its probability equals the level of significance, denoted $\alpha$. Type II Error (β): Failing to reject (accepting) a null hypothesis $H0$ when it is actually false. Its probability is denoted $\beta$. Decision $H0$ Tru...

Open this answer on its own page →

one sample tests for mean of normal population

2081 · 5 marks

The mean drying time of a brand of spray paint is known to be 122 seconds. The research division of the company that produces this paint contemplates that adding a new chemical ingredient to the paint accelerate the drying process. To investigate this conjecture, the paint with the chemical additions is sprayed on 50 surfaces and the drying time is recorded. The mean and standard deviation of drying time computed from these recorded are found as 116 seconds and 16.8 seconds respectively. Does these data provide strong evidence that the mean drying time is reduced by the addition of the new chemical? Use 5% level of significance. Also find p-value. [5]

Show solved answer

Hypothesis Test: Mean Drying Time of Spray Paint

Given Data

  • Population (claimed) mean: $\mu_0 = 122$ seconds
  • Sample size: $n = 50$
  • Sample mean: $\bar{X} = 116$ seconds
  • Sample standard deviation: $s = 16.8$ seconds
  • Significance level: $\alpha = 0.05$

Step 1: Hypotheses

  • $H_0: \mu = 122$ (no reduction)
  • $H_1: \mu < 122$ (drying time reduced) - left-tailed test

Step 2: Test Statistic

Since $n = 50 > 30$, use the Z-test: $$Z = \frac{\bar{X} - \mu_0}{s/\sqrt{n}}$$

Step 3: Calculation

$$s/\sqrt{n} = \frac{16.8}{\sqrt{50}} = \frac{16.8}{7.0711} = 2.3759$$

$$Z = \frac{116 - 122}{2.3759} = \frac{-6}{2.3759} = -2.525$$

Step 4: Critical Value

Left-tailed at $\alpha = 0.05$: $Z_{tab} = -1.645$

Step 5: Decision

Since $Z_{cal} = -2.525 < -1.645$, we reject $H_0$.

Step 6: P-value

$$p = P(Z < -2.525) = 1 - P(Z < 2.525) = 1 - 0.9942 = 0.0058$$

Since $p = 0.0058 < \alpha = 0.05$, reject $H_0$.

Conclusion

The data provide strong evidence at the 5% level of significance that the new chemical additive reduces the mean drying time below 122 seconds. The small p-value ($\approx 0.0058$) confirms high significance.

Open this answer on its own page →

2078 · 5 marks

Hypothesis Testing for Average Age of CSIT Students

Step 1: Set up Hypotheses

  • Null Hypothesis (H₀): $\mu = 22$ (The average age of enrolling students is 22 years)
  • Alternative Hypothesis (H₁): $\mu < 22$ (The average age is less than 22 years)

This is a left-tailed test at 5% level of significance.

Step 2: Sample Data

| 20 | 19 | 22 | 23 | 19 | 20 | 20 | 21 | 22 | 20 | 19 | 20 |

Sample size: $n = 12$

Step 3: Calculate Sample Statistics

Sample mean: $$\bar{x} = \frac{20 + 19 + 22 + 23 + 19 + 20 + 20 + 21 + 22 + 20 + 19 + 20}{12} = \frac{245}{12} = 20.417$$

Sample standard deviation: $$s = \sqrt{\frac{\sum(x_i - \bar{x})^2}{n-1}} = \sqrt{\frac{26.917}{11}} = \sqrt{2.447} = 1.564$$

Step 4: Test Statistic

Since the population is normally distributed and population standard deviation is unknown, we use the t-test:

$$t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}} = \frac{20.417 - 22}{1.564/\sqrt{12}} = \frac{-1.583}{0.451} = -3.511$$

Step 5: Critical Value

For a left-tailed test with $\alpha = 0.05$ and $df = n - 1 = 11$: $$t_{0.05, 11} = -1.796$$

Step 6: Decision

Since $t = -3.511 < -1.796$, we reject the null hypothesis.

Conclusion: At the 5% level of significance, there is sufficient evidence to support the researcher's doubt that the average age of CSIT enrolling students is less than 22 years. [5]

  • Claimed population mean: $\mu0 = 22$ years - Sample data: 20, 19, 22, 23, 19, 20, 20, 21, 22, 20, 19, 20 - Sample size: $n = 12$ - Level of significance: $\alpha = 0.05$ - Population normal, population SD unknown → one-sample t-test - $H0: \mu = 22$ (average age is 22 years) - $H1: \mu < 22$ (a...
Open this answer on its own page →

2077 · 5 marks

A dealer of a DELL company located at New Road claimed that the average lifetime of a multimedia projector produced by Dell Company is greater than 60,000 hours with standard deviation of 6000 hours. In order to test his claim, sample of 100 DELL projectors are taken and the average life time was monitored and it was found to be 55,000 hours. Test the claim of the dealer at 5% level of significance. [5]

Parameter Value ------------------ Claimed population mean $\mu = 60{,}000$ hours Population standard deviation $\sigma = 6{,}000$ hours Sample size $n = 100$ Sample mean $\bar{X} = 55{,}000$ hours Level of significance $\alpha = 0.05$ Since $n = 100$ (large) and $\sigma$ is known, a Z-test is us...

Open this answer on its own page →

test for single proportion

2081 · 5 marks

Discuss the concept of level of significance in hypothesis testing. A manufacturer of laptop provides a particular model in one of three colors. Of the first 100 laptops sold, it is noted that 80 were the first color. Can you conclude that more than two third of all the customers have a preference for the first color? Use 5% level of significance. [5]

Show solved answer

Level of Significance and Hypothesis Testing

Concept of Level of Significance

The level of significance (denoted α) is the probability of rejecting the null hypothesis $H_0$ when it is actually true. It is the maximum acceptable probability of committing a Type I error.

  • Fixed in advance of the test (typically $1%$, $5%$, or $10%$).
  • At $5%$ significance, we accept a $5%$ chance of wrongly rejecting a true $H_0$.
  • It determines the critical (tabulated) value used to bound the acceptance/rejection regions.
  • A smaller $\alpha$ makes the test more conservative (harder to reject $H_0$).

Numerical Solution

Given Data

ParameterValue
Sample size $n$$100$
Number preferring first color $x$$80$
Hypothesized proportion $P$$2/3 \approx 0.6667$
Level of significance $\alpha$$0.05$

Sample proportion: $$\hat{p} = \frac{x}{n} = \frac{80}{100} = 0.80$$


Step 1: Hypotheses

  • $H_0: P = \dfrac{2}{3}$ (two-thirds prefer the first color)
  • $H_1: P > \dfrac{2}{3}$ (more than two-thirds prefer the first color)

This is a right-tailed test.


Step 2: Test Statistic

$$Z = \frac{\hat{p} - P}{\sqrt{\dfrac{P(1-P)}{n}}}$$

Numerator: $$\hat{p} - P = 0.80 - 0.6667 = 0.1333$$

Denominator: $$\sqrt{\frac{0.6667 \times 0.3333}{100}} = \sqrt{\frac{0.2222}{100}} = \sqrt{0.002222} = 0.04714$$

Therefore: $$Z = \frac{0.1333}{0.04714} = 2.83$$


Step 3: Critical Value

For a right-tailed test at $\alpha = 0.05$: $$Z_{tab} = 1.645$$


Step 4: Decision

$$Z_{cal} = 2.83 > Z_{tab} = 1.645$$

Since the calculated value falls in the rejection region, reject $H_0$.


Step 5: Conclusion

At the $5%$ level of significance, there is sufficient evidence to conclude that more than two-thirds of all customers prefer the first color of the laptop.

Open this answer on its own page →

2080 · 5 marks

Define type I and type II error in testing of hypothesis. It is claimed that Samsung and Huawei mobiles are equally popular in Kathmandu. A random sample of 600 people from Kathmandu showed 350 have Samsung mobile. Test the claim at 5% level of significance. [5]

Show solved answer

Type I and Type II Errors + Test of Hypothesis on Mobile Popularity

Given Data

  • Sample size: $n = 600$
  • Number with Samsung: $X = 350$
  • Claim: equally popular, so $p_0 = 0.5$
  • Level of significance: $\alpha = 0.05$

Part 1: Type I and Type II Error

Type I Error ($\alpha$): Rejecting the null hypothesis $H_0$ when it is actually true. Its probability equals the level of significance $\alpha$.

Type II Error ($\beta$): Accepting the null hypothesis $H_0$ when it is actually false.

Decision$H_0$ True$H_0$ False
Accept $H_0$Correct DecisionType II Error ($\beta$)
Reject $H_0$Type I Error ($\alpha$)Correct Decision

Part 2: Test of Hypothesis

Step 1: Hypotheses

$$H_0: p = 0.5 \quad \text{(equally popular)}$$ $$H_1: p \neq 0.5 \quad \text{(not equally popular)} \quad \text{(two-tailed test)}$$

Step 2: Sample Proportion

$$\hat{p} = \frac{X}{n} = \frac{350}{600} = 0.5833$$

Step 3: Test Statistic (Z-test for proportion)

$$Z = \frac{\hat{p} - p_0}{\sqrt{\dfrac{p_0 q_0}{n}}}$$

where $q_0 = 1 - 0.5 = 0.5$.

$$\text{S.E.} = \sqrt{\frac{0.5 \times 0.5}{600}} = \sqrt{\frac{0.25}{600}} = \sqrt{0.0004167} = 0.020412$$

$$Z = \frac{0.5833 - 0.5}{0.020412} = \frac{0.0833}{0.020412} = 4.08$$

On the continuity correction: applying it gives $Z_{cal} = 4.04$; without it (the standard approach at this level) $Z = 4.08$. The two are numerically equivalent for the decision. Using the raw count form:

$$Z = \frac{X - np_0}{\sqrt{np_0 q_0}} = \frac{350 - 300}{\sqrt{150}} = \frac{50}{12.247} = 4.08$$

Step 4: Critical Value

At $\alpha = 0.05$, two-tailed:

$$Z_{\alpha/2} = Z_{0.025} = 1.96$$

Step 5: Decision

$$|Z| = 4.08 > 1.96$$

Since the calculated value exceeds the critical value, we reject $H_0$.

Step 6: Conclusion

At the 5% level of significance, there is sufficient evidence to reject the claim that Samsung and Huawei mobiles are equally popular in Kathmandu. The data indicates Samsung is significantly more popular.


Final Result: $Z_{cal} = 4.08$ (without continuity correction) vs $Z_{tab} = 1.96$; reject $H_0$. With the continuity correction $Z_{cal} = 4.04$, and the decision and conclusion are identical.

Open this answer on its own page →

2079 · 5 marks

It is claimed that Samsung and Redmi mobiles are equally popular in Kathmandu. A random sample of 500 people from Kathmandu showed 300 have Samsung mobile. Test the claim at 5% level of significance. [5]

  • Sample size: $n = 500$ - Samsung users: $X = 300$ - Level of significance: $\alpha = 0.05$ - Claimed proportion (equal popularity): $p0 = 0.5$ --- Sample proportion: $$\hat{p} = \frac{X}{n} = \frac{300}{500} = 0.60$$ - $H0: p = 0.5$ (Samsung and Redmi are equally popular) - $H1: p \neq 0.5$ (no...
Open this answer on its own page →

test for difference between two means and two proportions

2078 · 5 marks

The following are the details of working hours in the classroom per week of male and female faculty working in the area of Computer Science and Information Technology at Tribhuvan University. Apply independent t-test to examine the average working hour in the classroom per week is significantly different between male and female faculty, at 1% level of significance. State also null and alternative hypotheses appropriately.

Male FacultyFemale Faculty
Sample Size6030
Average working hours per week129
The standard deviation of a working hour per week43

[5]

Male Faculty Female Faculty --------- Sample size $n1 = 60$ $n2 = 30$ Mean working hours $\bar{X}1 = 12$ $\bar{X}2 = 9$ Standard deviation $S1 = 4$ $S2 = 3$ Level of significance: $\alpha = 0.01$ (two-tailed) --- Null Hypothesis $H0: \mu1 = \mu2$ There is no significant difference in average week...

Open this answer on its own page →

2078 · 5 marks

In location 1, there are 250 corona-positive cases out of 460 persons, and in location 2, 250 positive cases were reported out of 650 persons. Can it be concluded that the proportion of corona-positive cases is higher in location 1 compared to location 2? Test at a 10% level of significance. [5]

Location 1 Location 2 --------- Sample size $n1 = 460$ $n2 = 650$ Positive cases $x1 = 250$ $x2 = 250$ Level of significance: $\alpha = 0.10$ --- $$\hat{p}1 = \frac{250}{460} = 0.5435$$ $$\hat{p}2 = \frac{250}{650} = 0.3846$$ --- - $H0: P1 = P2$ (proportions equal in both locations) - $H1: P1 P2$...

Open this answer on its own page →

2075 · 10 marks

What do you mean by hypothesis? Describe null and alternative hypothesis. A company claims that its light bulbs are superior to those of the competitor on the basis of study which showed that a sample of 40 of its bulbs had an average life time 628 hours of continuous use with a standard deviation of 27 hours. While sample of 30 bulbs made by the competitor had an average life time 619 hours of continuous use with a standard deviation of 25 hours. Test at 5% level of significance, whether this claim is justified.[10]

A hypothesis is a tentative statement or assumption about a population parameter (mean, proportion, variance, etc.) that is subject to verification using sample data through statistical testing. The null hypothesis is a statement of "no difference" or "no effect." It assumes that any observed dif...

Open this answer on its own page →

Linkage between confidence interval and testing of hypothesis

2077 · 5 marks

Independent t-test and Confidence Interval Analysis

Based on the following information, perform the following:

a. Test whether two means are significantly different (α = 5%) using independent t-test.

b. Compare 95% confidence interval estimation for the difference of means.

c. Show the linkage between testing of hypothesis and confidence interval estimation in this problem.

Group IGroup B
Sample mean1015
Sample Standard Deviation35
Sample Size4964

[5]

Group I Group B --------- Sample mean $\bar{X}1 = 10$ $\bar{X}2 = 15$ Sample SD $S1 = 3$ $S2 = 5$ Sample size $n1 = 49$ $n2 = 64$ - Significance level: $\alpha = 0.05$ - Confidence level: 95% Note: Both samples are large ($n1, n2 30$), so the sampling distribution is approximately normal and

Open this answer on its own page →