Confidence intervals can be calculated using the following formula:
\[ CI = \bar{X} \pm Z_{\alpha/2} \cdot \frac{\sigma}{\sqrt{n}} \]
Where:
The sample mean and the standard error are used to estimate the confidence interval as follows:
\[ \text{Sample Mean} = \frac{1}{n} \sum_{i=1}^n X_i \]
\[ \text{Standard Error} = \frac{s}{\sqrt{n}} \]
Where \(s\) is the sample standard deviation, calculated as:
\[ s = \sqrt{\frac{1}{n-1} \sum_{i=1}^n (X_i - \bar{X})^2} \]
| Sample_Mean | CI_Lower | CI_Upper |
|---|---|---|
| 170.9 | 169.11 | 172.69 |
ggplot(data.frame(data), aes(x = data)) + geom_histogram(aes(y = ..density..), bins = 20, color = “black”, fill = “lightblue”) + geom_vline(xintercept = sample_mean, color = “blue”, linetype = “dashed”, size = 1) + geom_vline(xintercept = ci_lower, color = “red”, linetype = “dashed”, size = 0.8) + geom_vline(xintercept = ci_upper, color = “red”, linetype = “dashed”, size = 0.8) + labs(title = “Sampling Distribution with 95% Confidence Interval”, x = “Sample Data”, y = “Density”)