# Quiz 9 Question 8
data <- c(18.58748, 14.55368, 16.29175, 14.01600, 15.32540, 13.55354, 14.24206, 14.80121, 14.92051, 18.77165)

# calculate the sample mean and standard deviation
sample_mean <- mean(data)
sample_sd <- sd(data)

# standard error of the mean
se <- sample_sd / sqrt(length(data))

# Degrees of freedom
df <- length(data) - 1

# margin of error for 95%
margin_of_error <- qt(0.975, df) * se

# calculate the confidence interval
confidence_interval <- c(sample_mean - margin_of_error, sample_mean + margin_of_error)

cat("95% Confidence Interval: [", round(confidence_interval[1], 3), ", ", round(confidence_interval[2], 3), "]")
## 95% Confidence Interval: [ 14.196 ,  16.816 ]