MulaiMulai sekarang secara gratis

Confidence interval by hand

There are two common ways that interviewers will touch on confidence intervals; they will either ask you to explain it in simple terms, or elaborate on how they are calculated, possibly having you implement one. In this exercise, you'll practice the latter by producing a confidence interval by hand, using no packages other than those imported for you.

We have gone ahead and assigned the appropriate z-score for a 95% confidence interval and sample mean to the z_score and sample_mean variables to simplify things a bit.

Latihan ini adalah bagian dari kursus

Practicing Statistics Interview Questions in Python

Lihat Kursus

Petunjuk latihan

  • Compute the standard error and the margin of error using the sem() function and z_score variable imported for you.
  • Compute and print the lower boundary of our confidence interval using the sample_mean variable imported for you.
  • Compute and print the upper boundary of our confidence interval using the sample_mean variable imported for you.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

from scipy.stats import sem, t
data = [1, 2, 3, 4, 5]
confidence = 0.95

# Compute the standard error and margin of error
std_err = sem(____)
margin_error = std_err * ____

# Compute and print the lower threshold
lower = sample_mean - ____
print(____)

# Compute and print the upper threshold
upper = sample_mean + ____
print(____)
Edit dan Jalankan Kode