How to calculate the grand mean?

The grand mean is the average of all the individual means in a dataset. To calculate the grand mean, add up all of the individual means and divide by the number of individual means. This will give you the grand mean for the dataset.

@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_text_area {
display:inline-block;
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
padding-left: 100px;
}

#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;
}

#buttonCalc {
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 */
}

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

.label_radio {
text-align: center;
}

td, tr, th {
border: 1px solid black;
}
table {
border-collapse: collapse;
}
td, th {
min-width: 50px;
height: 21px;
}
.table_span_a, .table_span_b, .table_span_c, .table_span_d, .table_span_e {
width: 100%;
display: block;
}

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

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

.label_radio {
text-align: center;
}

A grand mean is calculated as the average of the means of several groups.

To calculate the grand mean, simply enter the data values for up to five groups into the boxes below, then press the “Calculate” button.

Group 1

Group 2

Group 3

Group 4

Group 5

Grand Mean: 8.02778

function calc() {

//define addition function
function add(a, b) {return a + b;}

//get raw data for each group
var group_a = document.getElementById(‘a’).value.split(‘,’).map(Number);
var group_b = document.getElementById(‘b’).value.split(‘,’).map(Number);
var group_c = document.getElementById(‘c’).value.split(‘,’).map(Number);
var group_d = document.getElementById(‘d’).value.split(‘,’).map(Number);
var group_e = document.getElementById(‘e’).value.split(‘,’).map(Number);

//verify they exist
if (group_a.length < 2){ group_a = null};
if (group_b.length < 2){ group_b = null};
if (group_c.length < 2){ group_c = null};
if (group_d.length < 2){ group_d = null};
if (group_e.length < 2){ group_e = null};

var all_groups_holder = group_a.concat(group_b, group_c, group_d, group_e);
var all_groups = all_groups_holder.filter(function (el) {
return el != null;
});

//find total number of groups (k)
if (group_a != null) { var flag_group_a = 1; } else { var flag_group_a = 0;};
if (group_b != null) { var flag_group_b = 1; } else { var flag_group_b = 0;};
if (group_c != null) { var flag_group_c = 1; } else { var flag_group_c = 0;};
if (group_d != null) { var flag_group_d = 1; } else { var flag_group_d = 0;};
if (group_e != null) { var flag_group_e = 1; } else { var flag_group_e = 0;};

//find total number of groups (k)
if (group_a != null) { var mean_group_a = math.mean(group_a); } else { var mean_group_a = 0;};
if (group_b != null) { var mean_group_b = math.mean(group_b); } else { var mean_group_b = 0;};
if (group_c != null) { var mean_group_c = math.mean(group_c); } else { var mean_group_c = 0;};
if (group_d != null) { var mean_group_d = math.mean(group_d); } else { var mean_group_d = 0;};
if (group_e != null) { var mean_group_e = math.mean(group_e); } else { var mean_group_e = 0;};

var k = [flag_group_a, flag_group_b, flag_group_c, flag_group_d, flag_group_e].reduce(add, 0);

var mean = math.sum(mean_group_a,mean_group_b,mean_group_c,mean_group_d,mean_group_e)/k;

//output Grand Mean
document.getElementById('mean').innerHTML = mean.toFixed(5);
}

x