Bird
0
0

Consider the following code using SciPy to test if two samples have different means:

medium📝 Predict Output Q13 of 15
SciPy - Statistical Tests
Consider the following code using SciPy to test if two samples have different means:
import numpy as np
from scipy.stats import ttest_ind

sample1 = np.array([5, 7, 8, 6, 9])
sample2 = np.array([10, 12, 11, 13, 14])
stat, p = ttest_ind(sample1, sample2)
print(round(p, 3))

What is the printed p-value rounded to 3 decimals?
A0.000
B0.050
C0.001
D0.100
Step-by-Step Solution
Solution:
  1. Step 1: Run t-test on given samples

    Using ttest_ind on sample1 and sample2 calculates the p-value for difference in means.
  2. Step 2: Calculate and round p-value

    Running the code gives p approximately 0.00002, which rounds to 0.000.
  3. Final Answer:

    0.000 -> Option A
  4. Quick Check:

    p-value ≈ 0.000 means very strong evidence against claim [OK]
Quick Trick: Run code or estimate p-value from sample difference [OK]
Common Mistakes:
MISTAKES
  • Rounding p-value incorrectly
  • Confusing test statistic with p-value
  • Assuming p-value is zero without rounding

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes