Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Confidence Interval Calculator for a Population Mean

Enter the sample size, sample mean, standard deviation and confidence level. The calculator finds the confidence interval for the population mean (lower and upper bounds), the margin of error, and a table for common confidence levels.

For the standard deviation, enter the population standard deviation σ if you know it. If you do not, you can use the standard deviation of your sample instead, as long as the sample is large enough (30 or more as a rule of thumb). Enter the confidence level as a percentage (for example, 95 for 95%).
Result and graph
Enter numbers in the fields on the left and press "Calculate". The result and a graph will appear here.

What you can do on this page

  • Enter the sample size \(n\), the sample mean \(\bar{x}\), the standard deviation \(\sigma\) and the confidence level (%), and you get the confidence interval for the population mean (lower and upper bounds) on the spot
  • It also calculates the margin of error \(E\) (how far off, plus or minus, the estimate may be), the standard error and the critical value z for the confidence level
  • See the confidence intervals at common confidence levels such as 90%, 95% and 99% in one table, and check on a graph how the interval widens
  • A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
This calculator finds a confidence interval based on the normal distribution (the z method), for when the population standard deviation σ is known (or the sample is large enough to use the sample standard deviation instead). It does not handle confidence intervals based on the t-distribution, which are used when the sample is small and the population standard deviation is unknown.

What is this calculation used for?

What the "± points" in polls really tells you (news and politics)

The "margin of error" in a poll result such as "presidential approval at 45% (margin of error ±2.5 points)" is exactly the margin of error \(E\) on this page. For a poll with 45% approval and 1,600 respondents, the spread is \(\sigma = \sqrt{0.45 \times 0.55} \approx 0.497\), so at a 95% confidence level \(E = 1.96 \times 0.497 \div \sqrt{1600} \approx 0.024\) (about ±2.4 points). This assumes the share of answers can be approximated by a normal distribution. The "±2.5 points" in news reports matches an estimate made with 50% approval, where the spread is largest.
You will be able to judge for yourself whether news that "approval moved 1 point" is within the margin of error.

Quality control in a factory: backing up the "500 mL" label with numbers (manufacturing)

A factory cannot open and measure every bottle, so it checks a sample. If 50 bottles (the standard 500 mL, or 16.9 fl oz, size) average 500.2 mL with a standard deviation of 2 mL, the 95% confidence interval for the average content of everything produced is about 499.65 to 500.75 mL.
Checking statistically, from sample inspections alone, that products are not below the labeled amount is a calculation used every day in food, beverage and drug manufacturing.

Reading how sure we are that a new treatment works (medicine)

Results in medical papers are almost always reported with a confidence interval, as in "the new drug lowered blood pressure by 8.0 mmHg on average (95% confidence interval: 5.6 to 10.4)". In a 100-person study where the drops have a standard deviation of 12 mmHg, \(E = 1.96 \times 12 \div \sqrt{100} \approx 2.4\).
If the whole interval is on the plus side (it does not include 0), that supports "the drug had an effect". If the interval includes 0, read it as "it may be chance". This is one of the most important ways to read health information for yourself.

Running a national survey without asking everyone (sample surveys in education and government)

Testing every student in the country is a huge job, so national studies of fitness and achievement are often done with samples. For example, if a sample of 400 students has an average 50-meter dash time of 9.2 seconds with a standard deviation of 0.8 seconds, the 95% confidence interval for the average time of all students is about 9.12 to 9.28 seconds. Just 400 students give a fairly narrow range.
Government statistics, such as the Current Population Survey behind the monthly unemployment rate, are also based mainly on samples, and this calculation backs up how precise they are.

Telling real improvements from noise on a website (IT and marketing)

When the average time on your site goes up from 180 seconds to 184 seconds, is that the effect of your change, or just chance? With 2,500 visitors and a standard deviation of 90 seconds, the 95% confidence interval for the average time is about 176.5 to 183.5 seconds, so there is a range of about ±3.5 seconds.
If a change is about the same size as the width of the confidence interval, you can tell it "cannot yet be told apart from chance". This idea is the foundation for not misreading A/B test results.

Formula and graph

Margin of error \(E\) (half the width of the interval)
Graph
Standard notation (the usual math form)
\(E\) \(=\) \(z\) \(\times\) \(\sigma\) \(\div\) \(\sqrt{n}\)
In words (symbols replaced with words)
④ \(E\): margin of error \(=\) ③ \(z\): critical value for the confidence level \(\times\) ① \(\sigma\): population standard deviation \(\div\) ② \(\sqrt{n}\): square root of the sample size \(n\)
The formula in words
① Take the \(\sigma\): population standard deviation
② divide it by the \(\sqrt{n}\): square root of the sample size \(n\) to get the standard error (the spread of the sample mean)
③ multiply by the \(z\): critical value for the confidence level
④ and you get the \(E\): margin of error
Quick example
You check the contents of 25 bottles. With a standard deviation of 2 mL and a 95% confidence level (z = 1.96), the margin of error is
\(E\): margin of error \(=\) z (1.96) \(\times\) standard deviation (2) \(\div\) square root of 25 (5)
\(1.96 \times 2 \div 5 = 1.96 \times 0.4 = 0.784\)
Key idea
\(\sigma \div \sqrt{n}\) is called the standard error. It is the size of the spread of the sample mean itself. The key point is that you divide by \(\sqrt{n}\) (the square root), not by \(n\): making the sample 4 times larger only cuts the margin of error in half. This is why you need a lot of data to gain precision.
Confidence interval (lower bound \(L\) and upper bound \(U\))
Graph
Standard notation (the usual math form)
\(L,\ U\) \(=\) \(\bar{x}\) \(\pm\) \(E\)
In words (symbols replaced with words)
③ \(L\), \(U\): lower and upper bounds of the confidence interval \(=\) ① \(\bar{x}\): sample mean \(\pm\) ② \(E\): margin of error
The formula in words
① From the \(\bar{x}\): sample mean
② subtract and add the \(E\): margin of error (the symbol ± stands for both "minus" and "plus")
③ and you get the \(L\), \(U\): lower and upper bounds of the confidence interval
Quick example
If the average content of the 25 bottles is 500.2 mL and the margin of error is 0.784 mL, the 95% confidence interval for the population mean is
\(L\), \(U\): lower and upper bounds of the confidence interval \(=\) sample mean (500.2) \(\pm\) margin of error (0.784)
\(L = 500.2 - 0.784 = 499.416\)
\(U = 500.2 + 0.784 = 500.984\)
Key idea
Put the first two formulas together and you get the familiar textbook formula for a confidence interval, \(\bar{x} \pm z \dfrac{\sigma}{\sqrt{n}}\). Be careful how you read "95% confidence interval". It does not say "the population mean is inside this interval with 95% probability". It says "if you repeated the process of taking a sample and building an interval the same way 100 times, about 95 of those intervals would contain the population mean". The population mean is one fixed value; it is the interval that moves from sample to sample.
Finding the critical value z from the confidence level
Graph
Standard notation (the usual math form)
\(z\) \(=\) \(\Phi^{-1}\!\left(\dfrac{1+C}{2}\right)\)
In words (symbols replaced with words)
② \(z\): critical value for the confidence level \(=\) ① the share counted from the left, (1 + confidence level \(C\)) ÷ 2, turned into a position on the z axis
The formula in words
① Find the share counted from the left, (1 + confidence level \(C\)) ÷ 2, turned into a position on the z axis (\(\Phi^{-1}\), "phi inverse", is the function that turns "a share counted from the left" into "a position on the horizontal axis". Write the confidence level \(C\) as a decimal, such as 0.95 for 95%)
② and that is the \(z\): critical value for the confidence level
Quick example
The critical value z for a 95% confidence level (C = 0.95) is
critical value \(z\) \(=\) position 97.5% from the left, \(\Phi^{-1}(0.975)\)
\(\Phi^{-1}\!\left(\dfrac{1+0.95}{2}\right) = \Phi^{-1}(0.975) \approx 1.96\)
Key idea
The critical value z is the boundary on the standard normal distribution that holds exactly the confidence level (95% for 95%) in the middle. With 95% in the middle, 2.5% is left in each tail, so z is the position 97.5% from the left: \(\Phi^{-1}(0.975) \approx 1.96\). The common values are fixed: 90% → 1.6449, 95% → 1.9600, 99% → 2.5758, 99.9% → 3.2905. This calculator also works out less common confidence levels that are not in the table (for example, 97%).
A confidence interval is "sample mean ± margin of error". The margin of error is \(z \times \sigma \div \sqrt{n}\), so all together it is \(\bar{x} \pm z \dfrac{\sigma}{\sqrt{n}}\). The larger the sample (the larger \(\sqrt{n}\)), the narrower the interval; the higher the confidence level (the larger z), the wider the interval.

Symbols and terms

Symbols

\(n\) en The sample size: how many items or people you actually measured. (Example: measure 50 bottles and \(n = 50\))
\(\bar{x}\) x-bar The sample mean, the average of the sample you measured. The bar on top is the sign for an average.
\(\sigma\) sigma The population standard deviation, the size of the spread in the whole population. A Greek letter that corresponds to the English s. If the sample is large enough, the standard deviation of the sample can be used instead.
\(\sqrt{n}\) square root of n The square root of the sample size (example: \(\sqrt{25} = 5\)). It appears in the denominator of the standard error, and it is the reason 4 times the data only cuts the error in half.
\(z\) zee (critical value) The multiplier set by the confidence level. It is the boundary on the standard normal distribution that holds exactly the confidence level in the middle. For 95%, it is about 1.96. It is also written z*.
\(E\) E The margin of error. It is half the width of the confidence interval and a guide to how far, plus or minus, the sample mean may be from the population mean. E stands for "error".
\(L,\ U\) L, U The lower and upper bounds of the confidence interval, found with \(L = \bar{x} - E\) and \(U = \bar{x} + E\).
\(\Phi^{-1}\) phi inverse (inverse of Φ) The function that works the other way from \(\Phi\), the cumulative distribution function of the standard normal distribution. It takes a probability (area) and returns the matching z. (Example: \(\Phi^{-1}(0.975) \approx 1.96\))
\(C\) C The confidence level written as a decimal. For 95%, \(C = 0.95\).

Terms

confidence interval A range estimated from sample data where the population mean is likely to be. It is built by extending the sample mean up and down by the margin of error.
confidence level How confident you can be in the interval. It is the share of intervals that would contain the population mean if you built intervals the same way over and over. 95% is used most often. It is also called the confidence coefficient.
population The whole group you would really like to study. (Examples - every bottle a factory makes, or every voter in the country)
sample The part of the population that you actually pick out and study. Using a sample to infer what the population looks like is what statistical estimation is about.
population mean The mean of the whole population. You cannot measure everything, so its exact value is unknown. A confidence interval estimates where this unknown value is. It is usually written \(\mu\) (mu).
sample mean The mean of the sample, \(\bar{x}\). It is the single most likely estimate of the population mean (a point estimate), but it changes a little every time depending on which sample you happen to take.
standard error The size of the spread of the sample mean itself, found with \(\sigma \div \sqrt{n}\). It is easy to confuse with the spread of the individual data values (the standard deviation), so be careful.
interval estimate A way to estimate an unknown value such as the population mean with a range instead of a single number. Compared with a point estimate, its strength is that it also shows how far off the estimate may be.
t-distribution The distribution used instead of the normal distribution (z) when the sample is small and the population standard deviation is unknown. The calculator on this page supports only the z method. As the sample gets larger, the t-distribution gets closer to the normal distribution and the results become almost the same.

Good to know before you start

Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.

The mean (Grade 6)
  • Knowing that you find the mean by adding up all the data and dividing by how many values there are
Square roots (Grade 8)
  • Knowing that a square root is the number that gives the original number when squared, as in \(\sqrt{25} = 5\)
Random sampling (Grade 7)
  • Knowing that instead of studying the whole (the population), you can study a part (a sample) and infer the whole
  • Knowing that the sample must be chosen without bias (at random)
Data analysis and standard deviation (high school statistics)
  • Knowing that the standard deviation is one number that shows how spread out the data is
The normal distribution and interval estimates (high school statistics / AP Statistics)
  • Knowing that the normal distribution is a symmetric bell shape centered on the mean
  • Knowing the rule of thumb that about 95% of a normal distribution lies within 1.96 standard deviations of the mean

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to find the critical value z for a confidence level
Confidence (%) 95
z =NORM.S.INV((1+B1/100)/2)
Table to find the margin of error E
z 1.96
Standard dev. σ 2
Sample size n 25
Margin of error E =B1*B2/SQRT(B3)
Table to find the confidence interval (lower and upper bounds)
Sample size n 50
Sample mean x̄ 500.2
Standard dev. σ 2
Confidence (%) 95
z =NORM.S.INV((1+B4/100)/2)
Margin of error E =B5*B3/SQRT(B1)
Lower bound =B2-B6
Upper bound =B2+B6
"NORM.S.INV(probability)" is the function that finds z from a probability (the inverse of the cumulative distribution function, \(\Phi^{-1}\)). "SQRT" is the square root.
The first table finds z from the confidence level (B1) alone; enter 95 and B2 is about 1.959964. The second table is the margin of error; with the example values, B4 is 0.784.
The third table finds the confidence interval from all the inputs at once. With the example values (n = 50, x̄ = 500.2, σ = 2, 95%), the lower bound (B7) is about 499.6456 and the upper bound (B8) is about 500.7544. Just replace B1 to B4 with your own numbers.

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to find the critical value z for a confidence level
Confidence (%) 95
z =NORMSINV((1+B1/100)/2)
Table to find the margin of error E
z 1.96
Standard dev. σ 2
Sample size n 25
Margin of error E =B1*B2/SQRT(B3)
Table to find the confidence interval (lower and upper bounds)
Sample size n 50
Sample mean x̄ 500.2
Standard dev. σ 2
Confidence (%) 95
z =NORMSINV((1+B4/100)/2)
Margin of error E =B5*B3/SQRT(B1)
Lower bound =B2-B6
Upper bound =B2+B6
In Google Sheets, the function that finds z from a probability is written "NORMSINV(probability)" (it works the same as "NORM.S.INV" in Excel). All the other formulas are the same as in Excel.
Copy the whole table, paste it into cell A1, and replace the numbers in column B with your own. The results are the same as in the Excel version: in the third table, the lower bound is about 499.6456 and the upper bound is about 500.7544.

How to calculate it in Python

import math
from statistics import NormalDist

sample_size = 50        # sample size n
sample_mean = 500.2     # sample mean x̄
sd = 2                  # standard deviation σ
confidence_level = 95   # confidence level (%)

z = NormalDist().inv_cdf((1 + confidence_level / 100) / 2)  # critical value z for the confidence level
standard_error = sd / math.sqrt(sample_size)                # standard error σ ÷ √n
margin_of_error = z * standard_error                        # margin of error E
lower = sample_mean - margin_of_error                       # lower bound of the confidence interval
upper = sample_mean + margin_of_error                       # upper bound of the confidence interval

print(f"z: {z}")
print(f"Margin of error E: {margin_of_error}")
print(f"{confidence_level}% confidence interval: {lower} to {upper}")
Runs with the standard library only. NormalDist().inv_cdf() is the function that finds z from a probability (\(\Phi^{-1}\)). Replace the first four values with your own numbers and run it. With the example values, it shows about 499.65 to 500.75.

How to write it in LaTeX and other math languages (copy and paste)

Margin of error \(E\) (half the width of the interval)
E = z × σ ÷ √n
E = z \times \dfrac{\sigma}{\sqrt{n}}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>E</mi>
    <mo>=</mo>
    <mi>z</mi>
    <mo>&#x00D7;</mo>
    <mfrac>
      <mi>&#x3C3;</mi>
      <msqrt><mi>n</mi></msqrt>
    </mfrac>
  </mrow>
</math>
E = z sigma / sqrt(n)
z*sigma/Sqrt[n]
E := z*sigma/sqrt(n);
E = z*sigma/sqrt(n);
E = zσ/√n
Confidence interval (lower bound \(L\) and upper bound \(U\))
L = x̄ − E,  U = x̄ + E
L = \bar{x} - E,\quad U = \bar{x} + E
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>L</mi>
    <mo>=</mo>
    <mover><mi>x</mi><mo>&#x00AF;</mo></mover>
    <mo>&#x2212;</mo>
    <mi>E</mi>
    <mo>,</mo>
    <mspace width="1em"/>
    <mi>U</mi>
    <mo>=</mo>
    <mover><mi>x</mi><mo>&#x00AF;</mo></mover>
    <mo>+</mo>
    <mi>E</mi>
  </mrow>
</math>
L = bar x - E, U = bar x + E
{xbar - e, xbar + e}
L := xbar - E; U := xbar + E;
L = xbar - E; U = xbar + E;
L = x̄ - E, U = x̄ + E
Finding the critical value z from the confidence level
z = Φ⁻¹((1 + C) ÷ 2)
z = \Phi^{-1}\!\left(\dfrac{1+C}{2}\right)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>z</mi>
    <mo>=</mo>
    <msup><mi>&#x3A6;</mi><mrow><mo>&#x2212;</mo><mn>1</mn></mrow></msup>
    <mrow>
      <mo>(</mo>
      <mfrac>
        <mrow><mn>1</mn><mo>+</mo><mi>C</mi></mrow>
        <mn>2</mn>
      </mfrac>
      <mo>)</mo>
    </mrow>
  </mrow>
</math>
z = Phi^-1((1 + C)/2)
InverseCDF[NormalDistribution[0, 1], (1 + c)/2]
with(Statistics): Quantile(RandomVariable(Normal(0, 1)), (1 + c)/2);
z = norminv((1 + c)/2);
z = Φ^(-1)((1+C)/2)

How to have ChatGPT  do the calculation

You are a statistics calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing).

50 bottles were taken off a factory line and their contents were measured. The mean was 500.2 mL. The spread of the fill amount (the population standard deviation) is known to be 2 mL.
1. Find the critical value z for a 95% confidence level (use the inverse of the cumulative distribution function of the standard normal distribution; Python's standard library statistics.NormalDist().inv_cdf can be used).
2. Find the margin of error E = z × σ ÷ √n.
3. Find the 95% confidence interval (lower and upper bounds) for the population mean (the true average content of all the bottles).

Show the formulas you used and the numbers from the execution result.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.