Published
Edited
Oct 7, 2020
1 star
Insert cell
Insert cell
Insert cell
sma([0, 1, 1, 1, 0, 0, 0, 10, 0, 1, 0, 0, 0, 1, 1], 4)
Insert cell
Insert cell
sma = (a,q) => {
if(q>a.length||q===1) throw "Invalid q.";
return a.slice(0,-(q-1)).map((_,i)=>a.slice(i,i+q).reduce((a,b)=>a+b)/q)
}
Insert cell
Insert cell
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