English

# Sample Mean and Covariance Calculator

Sample Mean and Covariance Calculator, is used to calculate the values of two or more variables from the set of data. Its an online probability and statistics tool to calculate the values of X mean, Y mean and Covariance (X,Y).

# Features

• Online calculator allows to find the sample mean, covariance between the two random variables.
• Calculation is based on the number of input values of the data sets.
• Responsive and supports all modern browsers.
• Note : Since it finds the covariance for X and Y, the number of values should be same for both X and Y.

# Preview

## Online Mean and Covariance Calculator

Result:

Code
<!-- Script by hscripts.com -->

<!-- More scripts @www.hscripts.com -->

<html>
<title>Sample Mean and Covariance Calculator Online Code</title>
<script type='text/javascript' >

{
var q=0;
var x=0;
var x1=0;
var n1=0;
var y=0;
var y1=0;
var n2=0;
var num=document.getElementById("t1").value;
var a=num.split(",");
var num1=document.getElementById("t2").value;
var b=num1.split(",");
a=a.filter(function(n){return n});
b=b.filter(function(n){return n});
var tot=a.length;
var tot1=b.length;
if(tot==0)
else if(tot1==0)
else if(tot==tot1)
{
for (var i=0;i<a.length;i++)
{
var d1=a[i];
if(d1[d1.length-1]==",")a[i]=d1.substring(0,(d1.length-1));
n1=(+n1)+(+a[i]);
var m1=n1/tot;
var m2=m1.toFixed(3);
document.getElementById("m").value=m2;
}
for (var i=0;i<b.length;i++)
{
var d1=b[i];
if(d1[d1.length-1]==",")b[i]=d1.substring(0,(d1.length-1));
n2=(+n2)+(+b[i]);
var s=n2/tot;
var s1=s.toFixed(3);
document.getElementById("m1").value=s1;
}
for (var k=0;k<b.length;k++)
{
var x=(+a[k])-(+m1);
var y=(+b[k])-(+s1);
var y1=(+x)*(+y);
q=q+y1;
}
var r1=q/tot;
document.getElementById("n").value=tot;
document.getElementById("res").value=r1;
}
else
{
alert("Number of values should be same for X and Y");
}
}
function res1()
{
document.getElementById("t1").value="";
document.getElementById("t2").value="";document.getElementById("m").value="";
document.getElementById("m1").value="";
document.getElementById("n").value="";
document.getElementById("res").value="";
}
function checnum(as)
{
var dd = as.value;
if(dd[dd.length-1]=="," && dd.length==1)
{as.value= dd.substring(0,(dd.length-1));
}
else if(dd[dd.length-1]==" ")
{as.value= dd.substring(0,(dd.length-1));
}
else
{var rr=dd.split(",");
for(var i=0;i<rr.length;i++)
{ if(isNaN(rr[i]) || rr[i]==" "){
dd=as.value;
dd = dd.substring(0,(dd.length-1));
if(i==0)as.value = dd;
else
as.value = dd;}
}
}
}
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");}
}
</script>
h2 {border-bottom: 1px solid #ebebeb;color: #474747;font-size: 1.2em;font-weight: normal;line-height: 130%;
}.div1{float:left;width:60%;line-height:60px;}textarea
{
width:30%;
min-height:50px;
height:auto;
background:#fff;
border:#ddd 1px solid;
margin-top:5px;
margin-bottom:15px;
}
.frms
{
margin:0 auto;
font-family:Tahoma, Geneva, sans-serif;
color:#333;
font-size:.9em;
line-height:1.2em;
}
.frms label {font-size: 1em;
}
.frms input[type="text"]
{
width:99%;
background:#fff;
border:#ddd 1px solid;
margin-top:5px;
margin-bottom:15px;
height:35px;
}
.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="button"],input[type="reset"]
{
font-weight:bold;
color:#fff;
cursor:pointer;
margin:10px 0;
border:none;
}
input[type="button"]
{
background:#468cd2;
border-bottom:#3277bc 3px solid;
}
.frms input[type="reset"]
{
background:#ee765d;
border-bottom:#d95e44 3px solid;
}
.resp_code
{
margin:5px 10px 10px 300px;
font:normal 1em/1.3em Tahoma, Geneva, sans-serif;
color:#333;
background:#f8f8f8;
border:#ddd 1px solid;
overflow:auto;width:50%;
}
@media screen and (max-width: 480px)
{
.resp_code
{width:auto !important;margin:0px !important;
}
.frms textarea{width:40%;min-height:50px;}.div1{float:left;line-height:20px;font-size:0.9em;}
}
</style></head><body><div class='resp_code'><div align='center'><h2>Online Mean and Covariance Calculator</h2></div><div class="frms" id='maindiv'>
<form name=first><div style='width:100%;padding-top:10px;'><div class='div1' align='left'><label>Enter the X Values (Separated by comma(,))</label></div><div style='width:100%;'><textarea rows=2 id=t1 cols=33 onkeyup=checnum(this) ></textarea></div></div><div style='width:100%;'><div class='div1' align='left'><label>Enter the Y Values (Separated by comma(,))</label></div><div style='width:100%;'><textarea rows=2 id=t2 cols=33 onkeyup=checnum(this) ></textarea></div></div><div align='center'><input type=button value=Calculate onclick=add()>
<input type=reset value=Reset onclick=res1()><span
<div class='result'><p align='center' style="font-size:1.1em;">Result:</p><div>
</html>
• Release Date - 09-03-2015
• For customization of this script or any script development, mail to support@hscripts.com

# Usage

• Copy and paste the code into your HTML page to use this sample mean and covariance calculator.
• Enter the X and Y values separated by comma and click calculate to find the mean and covariance.