The array to be counted is named data
var sum = function (x, y) {return x+y;}; sum function var square = function (x) {return x*x;}; Each element in the array asks for its square var data = [1 , 1 , 3 , 5 , 5 ]; var mean = data.reduce (sum)/data.length;var Deviations = Data.map (function (x) {return x mean;}); var StdDev = math.sqrt (Deviations.map (square). reduce (sum)/(Data.length-1 = Math.max.apply (Null,data) var Min = Math.min.apply (null,data)
var compare = function (x, y) {//Comparison function
if (x < y) {
return-1;
} else if (x > Y) {
return 1;
} else {
return 0;
}
};
var mid;//median
Data.sort (compare);//Array sort
if (data.length%2==0) {
Mid = (data[data.length/2]+data[ DATA.LENGTH/2+1])/2
}
if (data.length%2!=0) {
mid = data[(data.length+1)/2]
}
Console.log (" average value:" +mean);
Console.log (" deviation:" +deviations);
Console.log (" standard deviation:" +stddev);
Console.log (" maximum value:" +max);
Console.log (" Minimum Value:" +min);
Console.log ("median:" +mid);
Console.log ("top four min.:" +DATA[DATA.LENGTH/4]);
Console.log ("The next four cents:" +data[data.length/4*3]);
JS arithmetic group mean, maximum, minimum, deviation, standard deviation, median, array from small to large, top four, next four