0
0
SciPydata~30 mins

Wilcoxon signed-rank test in SciPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Wilcoxon Signed-Rank Test with SciPy
📖 Scenario: You are a data analyst working with a health study team. They collected blood pressure readings from 6 patients before and after a new treatment. You need to check if the treatment caused a significant change in blood pressure.
🎯 Goal: Build a Python program that uses the Wilcoxon signed-rank test to compare paired blood pressure readings before and after treatment.
📋 What You'll Learn
Create two lists called before and after with exact blood pressure values.
Create a variable called alpha and set it to 0.05 for significance level.
Use scipy.stats.wilcoxon to perform the Wilcoxon signed-rank test on before and after.
Print the test statistic and p-value with clear labels.
💡 Why This Matters
🌍 Real World
The Wilcoxon signed-rank test is used in medical studies, psychology, and other fields to compare paired samples when data may not be normally distributed.
💼 Career
Data analysts and scientists use this test to validate if treatments or interventions cause significant changes in paired observations.
Progress0 / 4 steps
1
Create blood pressure data lists
Create two lists called before and after with these exact values: before = [120, 130, 115, 140, 125, 135] and after = [118, 128, 117, 135, 130, 133].
SciPy
Need a hint?

Use square brackets to create lists and separate values with commas.

2
Set significance level
Create a variable called alpha and set it to 0.05 to represent the significance level.
SciPy
Need a hint?

Just assign 0.05 to a variable named alpha.

3
Perform Wilcoxon signed-rank test
Import wilcoxon from scipy.stats and use it to perform the Wilcoxon signed-rank test on the before and after lists. Store the result in a variable called test_result.
SciPy
Need a hint?

Use from scipy.stats import wilcoxon and call wilcoxon(before, after).

4
Print test statistic and p-value
Print the test statistic and p-value from test_result with labels exactly as: Test statistic: and p-value:.
SciPy
Need a hint?

Use print(f"Test statistic: {test_result.statistic}") and similarly for p-value.