Public
Edited
Aug 6, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mX = d3.mean(dataset.map(d => d.X))
Insert cell
stdX = d3.deviation(dataset.map(d => d.X))
Insert cell
Insert cell
Insert cell
Insert cell
function bootstrapSample(dataset) {
const bootstrapDataset = [];
const n = dataset.length;
for (let i = 0; i < n; i++) {
const randomIndex = Math.floor(Math.random() * n);
bootstrapDataset.push(dataset[randomIndex]);
}
return bootstrapDataset;
}
Insert cell
function kde(kernel, thresholds, data) {
return thresholds.map(t => ({
X: t,
Y: d3.mean(data, d => kernel(t - d))
}));
}
Insert cell
function epanechnikov(bandwidth) {
return x => Math.abs(x /= bandwidth) <= 1 ? 0.75 * (1 - x * x) / bandwidth : 0;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more