Get your own website Result Size: 625 x 565
x
 
# Specify sample mean (x_bar), sample standard deviation (s), sample size (n) and confidence level
x_bar = 62.1
s = 13.46
n = 30
confidence_level = 0.95
# Calculate alpha, degrees of freedom (df), the critical t-value, and the margin of error
alpha = (1-confidence_level)
df = n - 1
standard_error = s/sqrt(n)
critical_t = qt(1-alpha/2, 29)
margin_of_error = critical_t * standard_error
# Calculate the lower and upper bound of the confidence interval
lower_bound = x_bar - margin_of_error
upper_bound = x_bar + margin_of_error
# Print the results
sprintf("Critical t-value: %0.3f", critical_t)
sprintf("Margin of Error: %0.3f", margin_of_error)
sprintf("Confidence Interval: [%0.3f,%0.3f]", lower_bound, upper_bound)
sprintf("The %0.1f%% confidence interval for the population mean is:", confidence_level*100)
sprintf("between %0.4f and %0.4f", lower_bound, upper_bound)
[1] "Critical t-value: 2.045"
[1] "Margin of Error: 5.026"
[1] "Confidence Interval: [57.074,67.126]"
[1] "The 95.0% confidence interval for the population mean is:"
[1] "between 57.0740 and 67.1260"