Published
Edited
May 28, 2020
Insert cell
Insert cell
Insert cell
time_series = {
while (true) {
yield Promises.tick(100, Math.random());
}
}
Insert cell
mutable values = []
Insert cell
{
time_series;
return values
}
Insert cell
function windowed_average(series, length) {
if (values.length < length) {
values.push(series)
}
else {
values.shift()
values.push(series)
}
const sum = values.reduce((a, b) => a + b, 0);
const avg = (sum / values.length) || 0;
return avg
}
Insert cell
windowed_average(time_series, 10)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more