Published
Edited
Dec 7, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function ewa (decay, data, arr=[]) {
const beta = Math.E**(-1/decay);
const checkArr = (b) => {
return arr.length === 0
? R.prop('value', R.head(data))
: R.prop('value', arr[R.length(arr)-1]) * b + R.prop('value', data[1]) * (1-b)
};
if (R.length(data) === 0) return arr;
return ewa(
decay,
R.tail(data),
R.append(
R.pipe(
R.assoc('value', checkArr(beta)),
R.assoc('label', `${decay} Day`),
)(data[1]),
arr
),
);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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