Bird
0
0

What is the output of this code snippet?

medium📝 Predict Output Q4 of 15
SciPy - Statistical Tests
What is the output of this code snippet?
from scipy.stats import ks_2samp
sample1 = [10, 20, 30, 40, 50]
sample2 = [15, 25, 35, 45, 55]
result = ks_2samp(sample1, sample2)
print(round(result.statistic, 2))
A0.8
B0.4
C0.6
D0.2
Step-by-Step Solution
Solution:
  1. Step 1: Understand KS statistic

    The KS statistic is the maximum difference between the empirical CDFs of the two samples.
  2. Step 2: Calculate empirical CDF differences

    Samples are shifted by 5 units; the maximum difference in cumulative proportions is 0.2.
  3. Step 3: Round the statistic

    The computed KS statistic is 0.2, rounded to two decimals remains 0.2.
  4. Final Answer:

    0.2 -> Option D
  5. Quick Check:

    Check max difference between sorted cumulative distributions [OK]
Quick Trick: KS statistic = max difference between empirical CDFs [OK]
Common Mistakes:
MISTAKES
  • Confusing p-value with statistic
  • Not rounding the statistic correctly
  • Misunderstanding how KS statistic is computed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes