Hypothesis Testing in Medical Research
Learn how to formulate and test hypotheses using real women's health data. We'll use Python's scipy library to perform statistical tests.
Exercise: T-Test for Pain Levels
A group of 20 women reported their pain levels before and after a treatment. We want to test if there's a significant difference.
- Import scipy.stats
- Create two lists: before_treatment and after_treatment with the given data
- Perform a paired t-test
- Print the p-value
Hint: Use stats.ttest_rel()
for paired samples
from scipy import stats
# Pain levels before treatment
before_treatment = [7, 6, 8, 5, 7, 6, 8, 7, 6, 5,
8, 7, 6, 7, 8, 6, 5, 7, 8, 6]
# Pain levels after treatment
after_treatment = [5, 4, 6, 3, 5, 4, 6, 5, 4, 3,
6, 5, 4, 5, 6, 4, 3, 5, 6, 4]
# Perform the test
result = stats.ttest_rel(before_treatment, after_treatment)
# Print the p-value
print(f"P-value: {result.pvalue:.4f}")
# Output will appear here