Bird
0
0

What is wrong with this hypothesis test code?

medium📝 Debug Q7 of 15
SciPy - Statistical Tests
What is wrong with this hypothesis test code?
from scipy.stats import ttest_ind
sample1 = [1, 2, 3]
sample2 = [4, 5]
t_stat, p_val = ttest_ind(sample1, sample2, equal_var=False, alternative='greater')
print(p_val)
Aequal_var cannot be False
BSamples must be the same length
CThe 'alternative' parameter is not supported in this SciPy version
Dt_stat and p_val are reversed
Step-by-Step Solution
Solution:
  1. Step 1: Check SciPy ttest_ind parameters

    Older SciPy versions do not support 'alternative' parameter.
  2. Step 2: Identify parameter compatibility issue

    Using 'alternative' causes error if SciPy version is below 1.6.0.
  3. Final Answer:

    The 'alternative' parameter is not supported in this SciPy version -> Option C
  4. Quick Check:

    'alternative' param requires newer SciPy [OK]
Quick Trick: 'alternative' param needs SciPy 1.6.0+ [OK]
Common Mistakes:
MISTAKES
  • Assuming samples must be equal length
  • Misunderstanding equal_var usage
  • Swapping output variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes