Bird
0
0

What will be the p-value output of this code?

medium📝 Predict Output Q5 of 15
SciPy - Statistical Tests
What will be the p-value output of this code?
from scipy.stats import ks_2samp
import numpy as np
np.random.seed(0)
sample1 = np.random.normal(0, 1, 100)
sample2 = np.random.normal(0, 1, 100)
result = ks_2samp(sample1, sample2)
print(round(result.pvalue, 3))
A0.001
B0.500
C0.900
D0.050
Step-by-Step Solution
Solution:
  1. Step 1: Understand test on similar normal samples

    Both samples come from the same normal distribution, so p-value should be high, indicating no significant difference.
  2. Step 2: Check typical p-value range

    Running the code yields a p-value around 0.9, showing strong evidence samples are from same distribution.
  3. Final Answer:

    0.900 -> Option C
  4. Quick Check:

    High p-value means no difference [OK]
Quick Trick: Similar samples yield high p-value near 1 [OK]
Common Mistakes:
MISTAKES
  • Expecting low p-value for similar samples
  • Confusing statistic with p-value
  • Not setting random seed causing different results

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes