SU11
Hypothesis Tests Overview
• One population (𝜇): Use ttest_1samp to test if the sample mean equals a specified
population mean.
• Two independent populations (𝜇₁ and 𝜇₂): Use ttest_ind to compare the means of two
different populations.
• Two dependent populations (𝜇ₓ): Use ttest_rel for related samples to test the
difference in means between two related populations.
• Non-parametric tests: If normality is not met, use tests like wilcoxon for non-
parametric testing.
• Chi-squared tests: Used to test for goodness-of-fit or independence between variables
in frequency data.
2. Hypothesis Testing for One Population Mean
• Function: ttest_1samp(X, popmean=0)
• Example:
•
• Testing for normality: Use graphical tests like QQ-plot, boxplot, or histogram, and
perform the Shapiro-Wilk test using shapiro(X).
•
•
3. Hypothesis Testing for Two Independent Populations
• Function: ttest_ind(X1, X2, equal_var=True/False)
• Testing normality: Pool the centered and scaled samples, and use the Shapiro-Wilk
test.
•
• Equal variance: Use levene(X1, X2) to test if the variances are equal.
• Example: Test if the population mean body temperature of women is less than men
using ttest_ind.
•
• EQUALITY OF VARIENCES
•
•
• TTEST
4. Hypothesis Testing for Two Dependent Populations
• Function: ttest_rel(X1, X2) or ttest_1samp(difference)
• Example: Test if the mean body temperature after sleeping is lower than before using
ttest_rel.
•
• METHOD 1
•
• METHOD 2
5. Non-Parametric Tests
• One population (𝜈): Use the Wilcoxon test for non-parametric testing if normality is not
satisfied, wilcoxon(X - K).
•
• EXAMPLE:
•
• Two independent populations: Use the rank-sum test with ranksums(X1, X2).
EXAMPLE:
• Two dependent populations: Use wilcoxon on the differenced data.
•
• EXAMPLE:
6. Chi-Squared Tests
• Goodness-of-fit: chisquare(O, E) compares observed frequencies to expected ones.
•
• EXAMPLE: Chi-squared tests in Python (one-way tables) – Tabulated data
•
• EXAMPLE:
•
• Independence tests: Use chi2_contingency(M) for testing the independence between
two categorical variables.
•
• EXAMPLE: