What is Hypothesis Testing?
Hypothesis Testing is a statistical method used to make inferences or draw conclusions about a
population based on sample data. It involves testing an assumption (hypothesis) about a population
parameter (such as the mean or proportion) and deciding whether to reject or fail to reject the
hypothesis based on the sample data.
The process of hypothesis testing generally involves the following steps:
1. Formulating Hypotheses:
o Null Hypothesis (H₀): The hypothesis that there is no effect or no difference. It's the
assumption that we are testing against.
o Alternative Hypothesis (H₁ or Ha): The hypothesis that there is an effect or a
difference. It is what you want to prove or support.
2. Choosing the Significance Level (α):
o This is the probability threshold for rejecting the null hypothesis. Common values are
0.05, 0.01, or 0.10.
3. Selecting the Test Type:
o Choose an appropriate test (e.g., t-test, z-test) depending on the data type, sample
size, and assumptions about the population.
4. Performing the Test and Calculating the Test Statistic:
o Calculate a test statistic (like the z-score or t-statistic) based on the sample data.
5. Making a Decision:
o Compare the test statistic to a critical value from a statistical distribution or compute
a p-value. If the p-value is less than the significance level (α), reject the null
hypothesis.
6. Conclusion:
o Based on the comparison of the test statistic and critical value or p-value, either
reject or fail to reject the null hypothesis.
T-Test and Z-Test
Both the t-test and z-test are used for hypothesis testing, but they are used under different
conditions:
• Z-test is used when the population variance is known or when the sample size is large (n >
30).
• T-test is used when the population variance is unknown and the sample size is small (n ≤ 30).
T-Test
The t-test is used to compare the sample mean to the population mean or compare the means of
two samples. It is based on the t-distribution, which accounts for the variability when dealing with
small sample sizes.
Types of T-tests:
1. One-Sample T-test: Compares the sample mean to a known population mean.
2. Independent Two-Sample T-test: Compares the means of two independent samples.
3. Paired T-test: Compares means from the same group at two different times or under two
different conditions.
Formula for One-Sample T-test:
For comparing a sample mean (xˉ\bar{x}xˉ) to a population mean (μ\muμ):
t=xˉ−μsnt = \frac{\bar{x} - \mu}{\frac{s}{\sqrt{n}}}t=nsxˉ−μ
Where:
• xˉ\bar{x}xˉ = sample mean
• μ\muμ = population mean (under the null hypothesis)
• sss = sample standard deviation
• nnn = sample size
Steps for T-test:
1. Set up the null hypothesis (H0:μ=μ0H_0: \mu = \mu_0H0:μ=μ0) and alternative hypothesis.
2. Calculate the t-statistic using the formula.
3. Compare the t-statistic to the critical value from the t-distribution table (based on the
significance level and degrees of freedom).
4. If the t-statistic exceeds the critical value, reject the null hypothesis.
Z-Test
The z-test is used when the population variance is known or when the sample size is large. It uses the
z-distribution, which is a standard normal distribution.
Types of Z-tests:
1. One-Sample Z-test: Compares the sample mean to the population mean when the
population variance is known.
2. Two-Sample Z-test: Compares the means of two independent samples when the population
variances are known.
3. Z-test for Proportions: Used to test if the sample proportion differs from a known population
proportion.
Formula for One-Sample Z-test:
For comparing a sample mean (xˉ\bar{x}xˉ) to a population mean (μ\muμ):
z=xˉ−μσnz = \frac{\bar{x} - \mu}{\frac{\sigma}{\sqrt{n}}}z=nσxˉ−μ
Where:
• xˉ\bar{x}xˉ = sample mean
• μ\muμ = population mean (under the null hypothesis)
• σ\sigmaσ = population standard deviation (known)
• nnn = sample size
Steps for Z-test:
1. Set up the null hypothesis (H0:μ=μ0H_0: \mu = \mu_0H0:μ=μ0) and alternative hypothesis.
2. Calculate the z-statistic using the formula.
3. Compare the z-statistic to the critical value from the z-distribution (usually at a significance
level of 0.05 or 0.01).
4. If the z-statistic exceeds the critical value, reject the null hypothesis.
Key Differences Between T-test and Z-test:
Feature T-test Z-test
Small sample sizes (n ≤ 30) and Large sample sizes (n > 30) or known
When to Use
unknown population variance. population variance.
Z-statistic (based on the normal
Test Statistic T-statistic (based on the t-distribution)
distribution)
Sample variance used, data is Population variance known, data is
Assumptions
approximately normal. approximately normal.
Standard
Sample standard deviation (s) Population standard deviation (σ)
Deviation
Common One-sample, two-sample z-tests, and z-
One-sample, two-sample, paired t-tests
Applications tests for proportions