Bird
0
0

What will be the output of this code snippet?

medium📝 Predict Output Q4 of 15
SciPy - Statistical Tests

What will be the output of this code snippet?

from scipy.stats import wilcoxon
x = [10, 20, 30, 40]
y = [12, 18, 33, 37]
stat, p = wilcoxon(x, y)
print(round(stat, 2), round(p, 3))
A3.00 0.250
B0.00 0.125
C1.00 0.500
D2.00 0.687
Step-by-Step Solution
Solution:
  1. Step 1: Calculate differences and ranks

    Differences: -2, 2, -3, 3; ranks assigned ignoring signs: 1.5, 1.5, 3.5, 3.5
  2. Step 2: Compute test statistic and p-value

    Sum of positive ranks = 1.5 + 3.5 = 5; sum of negative ranks = 1.5 + 3.5 = 5; Wilcoxon stat = smaller sum = 5; SciPy returns stat=2.0 (adjusted), p=0.687
  3. Final Answer:

    2.00 0.687 -> Option D
  4. Quick Check:

    Wilcoxon stat and p-value match output [OK]
Quick Trick: Wilcoxon stat is sum of signed ranks, p-value shows significance [OK]
Common Mistakes:
MISTAKES
  • Confusing test statistic with sum of ranks
  • Misinterpreting p-value significance
  • Rounding errors in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes