How to calculate the confidence interval?

To calculate the confidence interval, you first need to determine the mean, standard deviation, and sample size of the data set. Then, use the formula, (mean – (1.96*standard deviation/sqrt(sample size)), (mean + (1.96*standard deviation/sqrt(sample size)) to calculate the lower and upper bounds of the confidence interval. The number 1.96 is used because it is the z-score that corresponds to a 95% confidence level.

@import url(‘https://fonts.googleapis.com/css?family=Droid+Serif|Raleway’);

.axis–y .domain {
display: none;
}

h1 {
text-align: center;
font-size: 50px;
margin-bottom: 0px;
font-family: ‘Raleway’, serif;
}

p {
color: black;
margin-bottom: 15px;
margin-top: 15px;
font-family: ‘Raleway’, sans-serif;
}

#words {
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
}

#words_pad {
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
padding-left:100px;
}

#calcTitle {
text-align: center;
font-size: 20px;
margin-bottom: 0px;
font-family: ‘Raleway’, serif;
}

#hr_top {
width: 30%;
margin-bottom: 0px;
border: none;
height: 2px;
color: black;
background-color: black;
}

#hr_bottom {
width: 30%;
margin-top: 15px;
border: none;
height: 2px;
color: black;
background-color: black;
}

#words label, input {
display: inline-block;
vertical-align: baseline;
width: 350px;
}

#button {
border: 1px solid;
border-radius: 10px;
margin-top: 20px;
padding: 10px 10px;
cursor: pointer;
outline: none;
background-color: white;
color: black;
font-family: ‘Work Sans’, sans-serif;
border: 1px solid grey;
/* Green */
}

#button:hover {
background-color: #f6f6f6;
border: 1px solid black;
}

.label_radio {
text-align: center;
}

This calculator creates a using the following formula:

Confidence Interval = x +/- z*(s/√n)

where:

  • x: sample mean
  • z: z-value that corresponds to confidence level
  • s: sample standard deviation
  • n: sample size

To create a confidence interval for a population mean, simply fill in the values below and then click the “Calculate” button:

90% Confidence Interval: (5.896, 28.104)

95% Confidence Interval: (3.770, 30.230)

99% Confidence Interval: (-0.388, 34.388)

function calc() {

//get input degrees of freedom, t-value
var mean = document.getElementById(‘mean’).value*1;
var sd = document.getElementById(‘sd’).value*1;
var n = document.getElementById(‘n’).value*1;

//define z-scores to use
var z_90 = 1.645;
var z_95 = 1.96;
var z_99 = 2.576;

//calculate intervals
var low_90 = mean – (z_90 * (sd/(Math.sqrt(n))));
var high_90 = mean – (-1*(z_90 * (sd/(Math.sqrt(n)))));

var low_95 = mean – (z_95 * (sd/(Math.sqrt(n))));
var high_95 = mean – (-1*(z_95 * (sd/(Math.sqrt(n)))));

var low_99 = mean – (z_99 * (sd/(Math.sqrt(n))));
var high_99 = mean – (-1*(z_99 * (sd/(Math.sqrt(n)))));

//output values
document.getElementById(‘low90’).innerHTML = low_90.toFixed(3);
document.getElementById(‘high90’).innerHTML = high_90.toFixed(3);

document.getElementById(‘low95’).innerHTML = low_95.toFixed(3);
document.getElementById(‘high95’).innerHTML = high_95.toFixed(3);

document.getElementById(‘low99’).innerHTML = low_99.toFixed(3);
document.getElementById(‘high99’).innerHTML = high_99.toFixed(3);
}

x