Public
Edited
Jan 11, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataSet
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
meanDataSet
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
estimateNValue = meanDataSet[0].n
Insert cell
mathematicNValue = {
const max = d3.max(target),
size = target.length;

const n = max + max / size - 1;
return n;
}
Insert cell
meanDataSet = {
const data = [];
for (let n = nRange[0]; n < nRange[1]; ++n) {
data.push({
n,
diff: d3.mean(dataSet.filter((d) => d.n === n).map((d) => d.diff))
});
}

data.sort((a, b) => a.diff - b.diff);

return data;
}
Insert cell
dataSet = {
const data = [];
for (let n = nRange[0]; n < nRange[1]; ++n) {
for (let i = 0; i < trialRepeat; ++i) {
data.push({ m: mValue, n, d: selectMFromN(mValue, n) });
}
}

data.map((d) => {
d.diff = d3.mean(target.map((t, i) => Math.pow(t - d.d[i], 2)));
});

return data;
}
Insert cell
target = selectMFromN(mValue, targetNValue)
Insert cell
nRange = [50, 400]
Insert cell
/**
* Select m elements out of n-length array
**/
selectMFromN = (m, n) => {
const total = [...Array(n).keys()];
d3.shuffle(total);
const output = total.slice(0, m).sort((a, b) => a - b);
return output;
}
Insert cell
d3 = require("d3")
Insert cell
width = 800
Insert cell
height = (width * 9) / 16
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