Part 01
Introduction to Hypothesis Testing
Fardina F Alam
CMSC 320: Introduction to Data Science
Topics We Will Cover
CMSC320 Textbook Chapter: Chapter 8
01
What is Hypothesis Testing
02
Null and Alternative Hypothesis
03
Level of Significance 𝛂
04
Collect Data using Different Sampling Methods
05
Type I and II Error
“Data alone is not interesting.
It is the interpretation of the data that we are really interested in.”
Hypothesis Testing (Making Informed Decisions with Data)
Hypothesis Testing (HT)
Hypothesis testing is a statistical method used to make informed decisions or draw conclusions about a population based on a sample of data.
HOW HYPOTHESIS TESTING WORKS
1. Make assumption about population
2. Use sample to test assumption
Population: The entire group that you are interested in studying.
Sample: A subset of the population used for analysis.
Main Steps of Hypothesis Testing
Collect Data
Obtain a representative sample from the population.
Remember the importance of recognizing whether data is collected through an experimental design or observational study.
Sampling Method
Random sampling� • Every unit has equal chance of selection.
A sampling method is a process by which individual items/event (observational units) are selected from the population to be included in the sample. Common sampling methods:
Stratified sampling� • Population divided into meaningful groups (strata).� • Random samples taken from each group.
Cluster sampling� • Population divided into clusters (e.g., locations).� • Randomly select clusters and include all units inside.
Systematic sampling� • Random start → select every kth unit.
Convenience sampling (non-probability)� • Select easiest or most available participants.� • Fast but may introduce bias.
Examples: Sampling Methods
Two Hypotheses in Hypothesis Testing
Hypothesis: a claim we test using data (about a population).
no effect / no difference (current assumption)
real effect / difference (opposite of H₀)
Possible Outcomes of a Test
(We never “prove” H₀ true.)
Example: Candy Machine H₀ & Hₐ are mutually exclusive
Let’s say, it is believed that a candy making machine makes chocolate bars that are on average 5 gram in weight. A worker claims that the machine after maintenance no longer makes 5 gram bar. Write down H₀ and Hₐ.
Practice: Doctors believe that the average teen sleeps on average of no longer than 10 hours per day. A researcher believes that teens on average sleep longer. Write down H₀ and Hₐ.
Significance Level (α): How Much Evidence Do We Require?
Significance Level (α): The probability of rejecting the null hypothesis when it is actually true (Type I error).
Common Choices: α = 0.05 (5% Type I error rate) or 0.01 (1% Type I error rate) | Key Rule: Smaller α → stronger evidence required to reject H₀ ; always choose α before analyzing the data.
Example: New Headache Treatment
H₀ (Null): The treatment has no effect.
H₁ (Alt): The treatment reduces headaches.
Set α = 0.05�Accepts a 5% Type I error rate (rejecting H₀ falsely).
After the study: p-value = 0.03
Decision & Conclusion
p-value (0.03) < α (0.05)
→ Reject H₀
CONCLUSION
The result is statistically significant. There is sufficient evidence to conclude that the treatment reduces headaches.
A threshold chosen before analyzing results to decide how much evidence is required against H₀.
Collect Data → Choose a Test → Compute the Test Statistic
Compute the Test Statistic From sample data, calculate a number that measures how far the sample result is from what H₀ predicts
Common statistics: z, t
Interpretation: Larger ∣test statistic∣| sample is far from H₀ |→ stronger evidence against H₀
Example: Compare two means → compute a t-statistic
Choose a Statistical Test Choose based on the research question, data type, and study design:
After computing the test statistic, decide whether to reject H₀. Two equivalent ways to make a decision:
1. Critical Value Approach
Compare the calculated test statistic directly to a predetermined threshold critical value (cutoff).
2. p-value Approach
Determine the probability of obtaining sample results as extreme as the observed data.
Calculate p-value and compare it to significance level α.
cheBoth methods always yield the same conclusion when using the same test and α.
LATER TOPIC Decision Methods in Hypothesis Testing
LATER TOPIC Decision Methods in Hypothesis Testing
Rejection Region
(Critical Value Approach)
Focuses on values that are too extreme if H₀ were true.
If test statistic falls in:
→ Rejection Region: Reject H₀
→ Otherwise: Fail to Reject H₀
P-value Approach
(Probability Probability)
Probability of observing results this extreme if H₀ is true.
Decision Rule:
→ p ≤ α : Reject H₀
→ p > α : Fail to Reject H₀
Key Idea More extreme result → stronger evidence against H₀
How Confident Are You With Your Decision?
Hypotheses under test
H₀: μ = 5g | Hₐ: μ ≠ 5g
Possible Outcomes
Reject H₀ or Fail to Reject H₀
1. The Experiment
We sample 50 chocolate bars to calculate the average sample mass. Next, we calculated:
2. Observed Daily Trials
Suppose we receive these average values:
Monday → 5.12 grams
Wednesday → 5.75 grams
Friday → 7.82 grams
How confident can we be that we should reject H₀?
To answer this, we need a CONCRETE METHOD to evaluate the strength of our evidence.
Confidence Level (C) & Significance Level (α)
How confident are we in our decision?
Remember: Significance Level (α) is the risk of being wrong (rejecting a true H₀)
Confidence Level (C)
Relationship: α = 1 − C
Example: 95% confidence → α = 0.05
Interpretation
How to decide C or Alpha value?
The choice depends on several critical factors:
Use these factors as a general guide for choosing the most appropriate threshold for your hypothesis test.
Type I and Type II Errors
Common mistakes we can make in hypothesis testing
Type I Error (False Positive)
Reject H₀ when it is actually true
Type II Error (False Negative)
Fail to reject H₀ when it is actually false
These errors are crucial to consider because they directly affect the validity of conclusions drawn from statistical tests.
Practice Scenario
A company states their machine makes straws of 4mm diameter. A worker believes this is no longer true, sampling 100 straws at 99% confidence.
Task: Write down H₀, Hₐ, N, C, and α.
Example: What is Type I and II error?
Scenario: Let's say you're testing whether a new drug is effective in reducing blood pressure.
Your null hypothesis (H0): the drug has no effect on blood pressure
Your alternative hypothesis (H1): the drug reduces blood pressure on avg.
Collect data from a sample of patients and conduct a statistical test.