hynky's picture
hynky HF staff
update slider values + fix plotly errors + update jsons to exclude sciqa
7b37a0b
raw
history blame
475 Bytes
export function calculateRollingAverage(data, windowSize) {
let rollingAvg = [];
for (let i = 0; i < data.length; i++) {
if (i < windowSize - 1) {
rollingAvg.push(null); // Not enough data points to calculate average
} else {
let sum = 0;
for (let j = 0; j < windowSize; j++) {
sum += data[i - j];
}
rollingAvg.push(sum / windowSize);
}
}
return rollingAvg;
}