Public
Edited
Feb 10, 2023
Insert cell
Insert cell
randomData = new Array(1000)
.fill()
.map(() => Math.floor(Math.random() * 100 + 1))
Insert cell
mean = randomData.reduce((acc, cur) => acc + cur, 0) / randomData.length
Insert cell
geometricMean = getGeometricMean(randomData)
Insert cell
Plot.rectY(
randomData.map((value) => ({ value })),
Plot.binX({ y: "count" }, { x: { value: "value", interval: 4 } })
).plot()
Insert cell
function getGeometricMean(values) {
let log = 0;
values.forEach((value) => {
log += Math.log(value);
});
return Math.exp(log / values.length);
}
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