Bird
0
0

What will this code print?

medium📝 Predict Output Q5 of 15
SciPy - Statistical Functions (scipy.stats) Basics
What will this code print?
import numpy as np
from scipy.stats import t

data = np.array([10, 12, 14, 16, 18])
mean = np.mean(data)
sem = t.sem(data)
ci = t.interval(0.95, len(data)-1, loc=mean, scale=sem)
print(tuple(round(x, 1) for x in ci))
A(10.1, 17.9)
B(11.0, 17.0)
C(9.5, 18.5)
D(12.0, 16.0)
Step-by-Step Solution
Solution:
  1. Step 1: Calculate mean

    Mean of data = (10+12+14+16+18)/5 = 14
  2. Step 2: Calculate standard error of mean (sem)

    sem = standard deviation / sqrt(n), calculated by t.sem(data)
  3. Step 3: Calculate 95% confidence interval

    Using t.interval with df=4, loc=14, scale=sem gives interval approximately (10.1, 17.9)
  4. Final Answer:

    (10.1, 17.9) -> Option A
  5. Quick Check:

    Check mean and sem calculations match output [OK]
Quick Trick: Confidence interval centers on mean ± t*sem [OK]
Common Mistakes:
MISTAKES
  • Using incorrect degrees of freedom
  • Confusing standard deviation with sem
  • Rounding errors in interval calculation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes