English

# Empirical Rule Calculator Script

The free javascript calculator is used to find empirical rule for the set of values in statistics. The rule states that 68% of the values fall within the first standard deviation, 95% of the values fall within the first two standard deviations, and 99.7% of the values fall within the first three standard deviations of the mean. It is also known as 68-95-99.7 Rule or Three sigma rule.

# Features

• The empirical rule plays vital role in statistics.
• The javascript calculator gives quick estimate for the set of data in a normal distribution.
• Fully customizable and mobile friendly script.
• It works on all modern browsers.
• Just copy the code from textarea and paste it into your webpage/blog.

# Preview

## Empirical (68-95-99.7) Rule Calculator Script

#### Empirical Rule ( 68-95-99.7) in Statistics

Code

<script LANGUAGE="JavaScript" >
function isNum(arg)
{
var args = arg;
if (args == "" || args == null || args.length == 0)
{
return false;
}
args = args.toString();var len=args.length;
for (var i = 0;i<len;i++)
{
if (args.substring(i,i+1) < "0" || args.substring(i, i+1) > "9")
{
if(args.substring(i, i+1) == ".")
{
else
return false;
}
else
{
return false;
}
}
}
return true;
}
function calc()
{var sds = document.getElementById('dum');
if(sds != null)
{
var vva = document.getElementById("a11").value;
vva = vva.replace(" ","");
var resul;
var bb = true;
if(vva != "")
{
resul = vva.split(",");
}
for(var v=0; v<resul.length; v++)
{
var d = resul[v];
if(isNaN(d) || d == "")
{
alert("The number \""+d+"\" is not a valid one");
var bb = false;
break;
}
}
if(bb == true)
{
var tot = resul.length;
var mean=0;
document.getElementById("r1").value = tot;
for(var c=0; c<tot; c++)
{
mean = mean+parseFloat(resul[c]);
}
mean = mean/tot;
var mean1 =
mean.toFixed(1);
document.getElementById("r2").value= mean1;
var variance=0;
var b;
var varian;
for(var a=0; a<tot; a++)
{
variance = variance+Math.pow((parseFloat(resul[a])-mean),2);
b = tot-1;varian = variance/b;
}
var sd=0;
{

sd = Math.sqrt(varian);
var sd1 =sd.toFixed(1);
}
document.getElementById("r4").value = sd1;var f=(+mean)+(+sd1);var f=f.toFixed(1);var first1=mean-sd1;var first1=first1.toFixed(1);var m=sd1*2;var second=mean+m;var second=second.toFixed(1);var second1=mean-m;var second1=second1.toFixed(1);var m1=sd1*3;var third=mean+m1;var third=third.toFixed(1);var third1=mean-m1;var third1=third1.toFixed(1);
var val1 =" and " +f;
var rval5="68 % of the values fall between "+first1+val1;
var rval6="68 % of the values fall between "+first1+val1;
var rval7="68 % of the values fall between "+first1+val1;
document.getElementById("r5").value = rval5;
document.getElementById("r6").value = rval6;
document.getElementById("r7").value = rval7;
}
}
}
function re()
{
document.getElementById("a11").value="";
document.getElementById("r1").value="";
document.getElementById("r2").value="";
document.getElementById("r4").value="";
document.getElementById("r5").value="";
document.getElementById("r6").value="";
document.getElementById("r7").value="";
}
function chk(){
var sds = document.getElementById('dum');
if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");
document.getElementById("calc").style.visibility="hidden";
}
}
</script>
<style>.frms
{
margin:0 auto;
border:#ddd 1px solid;
font-family:Tahoma, Geneva, sans-serif;
color:#333;
font-size:.9em;
line-height:1.2em;
}
{
width:99%;
background:#fff;
border:#ddd 1px solid;
margin-top:5px;
margin-bottom:15px;
height:35px;
}
textarea
{
width:99%;
height:auto;
background:#fff;
border:#ddd 1px solid;
margin-top:5px;
margin-bottom:15px;
}
.frms input:hover,textarea:hover,select:hover
{
}
.frms input:focus,textarea:focus,select:focus
{
-webkit-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
-moz-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
border:#9d9983 1px solid;
}
.frms input[type="file"]
{
width:99.6%;
}
.frms input[type="submit"],input[type="reset"],input[type="button"],button,.yellow_button,.blue_button
{
font-weight:bold;
color:#fff;
cursor:pointer;
margin:10px 0;
border:none;
}
.frms input[type="submit"]
{
background:#75ab22;
border-bottom:#629826 3px solid;
}
.frms input[type="reset"]
{
background:#ee765d;
border-bottom:#d95e44 3px solid;
}
input[type="button"],button,.blue_button
{
background:#468cd2;
border-bottom:#3277bc 3px solid;
}
</style><div class="frms" id='calc'>
<h2>Empirical or 68-95-99.7 Rule Calculation
</h2>
<div class='clear'></div>
<form name=first>
<div id="dispCalcConts"><div class='group clearfix'>
<label>Enter all the numbers separated by comma</label>
<textarea id=a11 rows=2 cols=40 ></textarea>
<label style='color:#908C8C'>[E.g: 13,23,12,44,55]</label>
</div>
<div class='result'>
<div class='group clearfix'>
<label>Total Numbers:</label>
</div>
<div class='group clearfix'>
<label>Mean (Average):</label>
</div>
<div class='group clearfix'>
<label>Standard Deviation:</label>
</div>
<div align=center><h4>Empirical Rule</h4></div>
<div align=center><textarea id=r5 rows=2 cols=30 readonly></textarea></div>
<div align=center><textarea id=r6 rows=2 cols=30 readonly></textarea></div>
<div align=center><textarea id=r7 rows=2 cols=30 readonly></textarea></div></div>
</div>
</form></div>

• Release Date - 22-03-2015
• For customization of this script or any script development, mail to support@hscripts.com

# Usage

• Copy and paste the above code into your HTML page.
• Here, the function "calc()" is used to find the Empirical rule calculation.
• Enter all the fields and click calculate to view the results.