Coefficient of variation is represented as the ratio of the standard deviation to the mean . It is also know as unitized risk. This calculator helps to find out the coefficient of variation for set of numbers.
<!-- Script by hscripts.com -->
<!-- More scripts @www.hscripts.com -->
<html>
<head>
<title>Coefficient of Variation (CV) Calculator in Javascript </title><script type="text/javascript">
function checnum(as)
{var i;var a = as.value;as.value = a.replace(/[^\d,]/g, '');
}
function trimExtraComma(obj)
{var utext =obj.value.trim();
var firstChar = utext.substring(0, utext.length);
if(firstChar == ','){utext = utext.substring(1);}obj.value = utext.replace(/,+(?=,)/g,'');var val=document.getElementById("rvalue").value;var rary=val.split(",");var i;var k=rary.length;
for (i=0; i<k; i++){
if(rary[i].length>10) {
alert("Enter minimum 10 digits");
va='';
document.getElementById("rvalue").value =" ";va.replace(va,'');}}
}
function error()
{var t=document.getElementById("rvalue").value;
if (t!='') {
t = t.replace(" ","");var rarray=t.split(",");var k=rarray.length;
var sum=0;//Mean calculationfor(var c=0; c<k; c++){sum = sum + parseFloat(rarray[c]);}
mean = sum/k;//Variance calculation
var variance=0;var b;var varian;for(var a=0; a<k; a++)
{variance = variance+Math.pow((parseFloat(rarray[a])-mean),2);b = k-1;varian = variance/b;}//Standard Deviation Calculationvar sd=0;sd = Math.sqrt(varian); var coev = Math.round(100000 * (sd / mean)) / 100000;document.getElementById("evalue").value = coev;}
else{alert("Enter values to Calculate!");}
}
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("maindiv").style.visibility="hidden";
}
var sdss = document.getElementById("dumdiv");
if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
}
window.onload=chk;
</script>
<style>
h2 {border-bottom: 1px solid #ebebeb;color: #474747;font-size: 1.6em;font-weight: normal;line-height: 130%;
}
.frms
{
margin:0 auto;
padding:10px;
-moz-border-radius:.3em;
-webkit-border-radius:.3em;
-o-border-radius:.3em;
font-family:Tahoma, Geneva, sans-serif;
color:#333;
font-size:.9em;
line-height:1.2em;
}
.frms input[type="text"],[type="password"],[type="file"],textarea,select
{
width:99%;
background:#fff;
border:#ddd 1px solid;
border-radius:.35em;
-moz-border-radius:.35em;
-webkit-border-radius:.35em;
-o-border-radius:.35em;
padding:0 .5%;
margin-top:5px;
margin-bottom:15px;
height:35px;
}
.frms input:hover,textarea:hover,select:hover
{
box-shadow:#dae1e5 0px 0px 5px;
-moz-box-shadow:#dae1e5 0px 0px 5px;
-webkit-box-shadow:#dae1e5 0px 0px 5px;
-o-box-shadow:#dae1e5 0px 0px 5px;
}
.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="submit"],input[type="reset"],input[type="button"],button,.yellow_button,.blue_button
{
padding:7px 14px;
font-weight:bold;
color:#fff;
cursor:pointer;
border-radius:.3em;
-moz-border-radius:.2em;
-webkit-border-radius:.2em;
-o-border-radius:.2em;
margin:10px 0;
border:none;
}
.frms input[type="submit"]
{
background:#75ab22;
border-bottom:#629826 3px solid;
text-shadow:#396e12 1px 1px 0px;
}
.frms input[type="reset"]
{
background:#ee765d;
border-bottom:#d95e44 3px solid;
text-shadow:#8c3736 1px 1px 0px;
}
input[type="button"],button,.blue_button
{
background:#468cd2;
border-bottom:#3277bc 3px solid;
text-shadow:#214d73 1px 1px 0px;
}
.frms label
{
font-size:1.2em;
}
.resp_code
{
margin:5px 10px 10px 300px;
padding:10px 20px 10px 20px;
font:normal 1em/1.3em Tahoma, Geneva, sans-serif;
color:#333;
background:#f8f8f8;
border:#ddd 1px solid;
border-radius:.25em;
overflow:auto;width:50%;
}
@media screen and (max-width: 480px)
{
.resp_code
{width:auto !important;margin:0px !important;
}
}
</style>
</head><body><div class='resp_code'>
<div id='maindiv' class='frms'><div align='center'><h2>Coefficient of Variance (CV) Calculator</h2></div>
<form name=first class='frms noborders'>
<div align='left'><label>Enter the set of numbers (separated by comma)</label><input type=text id=rvalue onkeyup='checnum(this),trimExtraComma(this)'> </div> <div align=center> <input type=button value=Calculate onclick=error()> <input type='reset' value=Reset><span align='center' style="font-size: 10px;color: #dadada;" id="dumdiv"><a href="https://www.hscripts.com" id="dum" style="font-size: 10px;color: #dadada;text-decoration:none;color: #dadada;">©h</a></span>
</div>
<div class='result'><div align='left'>
<label>Coefficient of Variation (CV)</label><input type=text id=evalue readonly>
</div>
</div>
</form>
</div>
</div>
</body>
</html>