HomeStatistics & Probability › Confidence Interval Calculator

Confidence Interval Calculator

Computes a confidence interval for a population mean from the sample mean, standard deviation and sample size using the normal (z) critical value: mean ± z · s / √n.

When to use

You have a sample mean, its standard deviation and the sample size and want the interval that likely contains the population mean at a given confidence level.

Do not use when: The statistic is a proportion or survey percentage (use margin-of-error), or the sample is small (n < 30) with an unknown population SD, where a t-based interval is the correct choice and this z interval is slightly too narrow.

Formula

z = Φ⁻¹(1 − (1 − confidence_level_percent/100) / 2); standard_error = std_dev / √sample_size; margin_of_error = z × standard_error; interval = sample_mean ± margin_of_error

Uses the normal critical value, which is exact when the population σ is known and a good approximation when s is estimated from n ≥ 30 observations. For smaller samples with an estimated s, the Student t critical value with n − 1 degrees of freedom should replace z (e.g. 2.045 instead of 1.96 for n = 30 at 95 %).

Inputs

ParameterTypeUnitRequiredDescription
sample_meannumberyesMean of the sample.
std_devnumberyesPopulation standard deviation σ if known, otherwise the sample standard deviation s. Range: > 0
sample_sizeintegeryesNumber of observations in the sample. Range: ≥ 2
confidence_level_percentnumber%default 95Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value. Range: > 0

Outputs

OutputTypeUnitDescription
z_valuenumberTwo-sided standard normal critical value for the confidence level (1.6449 for 90 %, 1.96 for 95 %, 2.5758 for 99 %).
standard_errornumberstd_dev / √sample_size.
margin_of_errornumberz_value × standard_error (half-width of the interval).
lower_boundnumbersample_mean − margin_of_error.
upper_boundnumbersample_mean + margin_of_error.

Example

Mean 100, SD 15, n = 36, 95 %: {"sample_mean":100,"std_dev":15,"sample_size":36,"confidence_level_percent":95}{"z_value":1.96,"standard_error":2.5,"margin_of_error":4.9,"lower_bound":95.1,"upper_bound":104.9}

Mean 50, SD 8, n = 100, 99 %: {"sample_mean":50,"std_dev":8,"sample_size":100,"confidence_level_percent":99}{"z_value":2.5758,"standard_error":0.8,"margin_of_error":2.0607,"lower_bound":47.9393,"upper_bound":52.0607}

GET https://tttkmbb.com/api/v1/calculate/confidence-interval?sample_mean=100&std_dev=15&sample_size=36&confidence_level_percent=95

Machine access

Sources

FAQ

What does a 95 % confidence interval mean?

If the sampling were repeated many times and an interval computed each time, about 95 % of those intervals would contain the true population mean. It does not mean there is a 95 % probability that this particular interval contains it.

When should I use t instead of z?

When the population standard deviation is unknown and estimated from the sample, the t distribution with n − 1 degrees of freedom is the exact choice; for n ≥ 30 the difference from z is small (about 4 % wider at n = 30, under 1 % at n = 200).

Related calculators