0
0
SciPydata~20 mins

Wilcoxon signed-rank test in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Wilcoxon Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Wilcoxon test on paired samples
What is the output of the following code using scipy's Wilcoxon signed-rank test on paired samples?
SciPy
from scipy.stats import wilcoxon

sample1 = [20, 22, 19, 24, 30]
sample2 = [21, 20, 20, 25, 29]

stat, p = wilcoxon(sample1, sample2)
print(round(stat, 2), round(p, 3))
A7.5 1.000
B3.0 0.438
C2.0 0.688
D0.0 0.063
Attempts:
2 left
💡 Hint
Remember Wilcoxon test compares paired differences and returns a test statistic and p-value.
data_output
intermediate
1:30remaining
Number of zero differences excluded in Wilcoxon test
Given two paired samples, how many zero differences are excluded by the Wilcoxon signed-rank test in the following data?
SciPy
from scipy.stats import wilcoxon

x = [5, 7, 8, 6, 9]
y = [5, 6, 8, 7, 9]

stat, p = wilcoxon(x, y, zero_method='wilcox')
print(stat)
A3
B0
C1
D2
Attempts:
2 left
💡 Hint
Check how many pairs have zero difference between x and y.
🔧 Debug
advanced
1:30remaining
Identify the error in Wilcoxon test usage
What error will this code raise when running the Wilcoxon signed-rank test?
SciPy
from scipy.stats import wilcoxon

sample1 = [1, 2, 3]
sample2 = [1, 2]

stat, p = wilcoxon(sample1, sample2)
print(stat, p)
ANo error, outputs test statistic and p-value
BTypeError: wilcoxon() missing 1 required positional argument
CIndexError: list index out of range
DValueError: The samples must have the same length
Attempts:
2 left
💡 Hint
Check if the input arrays have the same length.
🚀 Application
advanced
1:30remaining
Choosing correct zero_method for Wilcoxon test
You have paired data with some zero differences. Which zero_method option in scipy.stats.wilcoxon excludes zero differences from ranking but keeps the sample size unchanged?
A'exclude'
B'wilcox'
C'pratt'
D'zsplit'
Attempts:
2 left
💡 Hint
Check scipy documentation for zero_method options.
🧠 Conceptual
expert
1:30remaining
Interpretation of Wilcoxon signed-rank test p-value
If the Wilcoxon signed-rank test returns a p-value of 0.02 for paired samples, what does this imply about the null hypothesis at a 5% significance level?
AThere is no evidence to reject the null hypothesis; the samples are identical.
BThere is strong evidence to reject the null hypothesis; the median difference is not zero.
CThe test is inconclusive; more data is needed.
DThe null hypothesis is accepted; the median difference is zero.
Attempts:
2 left
💡 Hint
Recall what a p-value less than significance level means.