confidence interval
confidence_intervalCalculate the confidence interval for a sample mean. Given a sample mean, sample size, standard deviation, and confidence level, computes the margin of error, lower and upper bounds, critical z-score, and standard error. Supports finite population correction (FPC) when a population size is provided, which narrows the interval for samples that are a large fraction of the population. Uses the Abramowitz & Stegun rational approximation for the inverse normal CDF to derive the critical z-value. Common in survey analysis, A/B testing, and quality control.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sample_mean | Yes | The observed sample mean (x-bar) around which the confidence interval is centered. | |
| sample_size | Yes | The number of observations in the sample (n). Must be a positive integer. | |
| population_size | No | Total population size for finite population correction (FPC). Omit for infinite population assumption. | |
| confidence_level | No | Confidence level as a decimal between 0 and 1 (e.g. 0.95 for 95%). Default is 0.95. | |
| standard_deviation | Yes | The standard deviation of the sample or population. Must be a positive number. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| z_score | Yes | Critical z-value used for the given confidence level. | |
| lower_bound | Yes | Lower bound of the confidence interval. | |
| upper_bound | Yes | Upper bound of the confidence interval. | |
| standard_error | Yes | Standard error of the mean, optionally adjusted with finite population correction. | |
| margin_of_error | Yes | Half-width of the confidence interval (z_score * standard_error). | |
| confidence_level | Yes | The confidence level used (echoed back). |