Cumulatieve frequentiecalculator
function calc() {
//remove current table if one exists var element = document.getElementsByTagName('table')[0]; if(element) {element.parentNode.removeChild(element)}
//get input values var input_data = document.getElementById('input_data').value.split(',').map(Number);
//calculate stuff var occurrence = function (array) { "use strict"; var result = {}; if (array instanceof Array) { // Check if input is array. array.forEach(function (v, i) { if (!result[v]) { // Initial object property creation. result[v] = [i]; // Create an array for that property. } else { // Same occurrences found. result[v].push(i); // Fill the array. } }); } return result; }; var size = Object.keys(occurrence(input_data)).length;
//create array of relative and cumulative values
var relFreqArray = [];
for (var i = 0; i < size; i++){
relFreqArray[i] = (occurrence(input_data)[Object.keys(occurrence(input_data))[i]].length)
}
for (var cumsum = [relFreqArray[0]], i = 0, l = relFreqArray.length-1; i