Bird
0
0

Identify the error in this code snippet for calculating a 90% confidence interval:

medium📝 Debug Q14 of 15
SciPy - Curve Fitting and Regression
Identify the error in this code snippet for calculating a 90% confidence interval:
from scipy.stats import t
sample_mean = 10
sample_std = 2
n = 25
se = sample_std / n
interval = t.interval(0.90, n-1, loc=sample_mean, scale=se)
print(interval)
ADegrees of freedom should be n, not n-1
BWrong confidence level value
CStandard error calculation is incorrect
Dt.interval function does not exist
Step-by-Step Solution
Solution:
  1. Step 1: Check standard error calculation

    Standard error should be sample_std divided by sqrt(n), not by n.
  2. Step 2: Verify other parts

    Confidence level 0.90 and degrees of freedom n-1 are correct; t.interval exists.
  3. Final Answer:

    Standard error calculation is incorrect -> Option C
  4. Quick Check:

    SE = std / sqrt(n), not std / n [OK]
Quick Trick: SE = std / sqrt(n), not std / n [OK]
Common Mistakes:
  • Dividing std by n instead of sqrt(n)
  • Confusing degrees of freedom
  • Using wrong confidence level format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes