import {palette, plotStyle, rng, mean} from "/_extensions/felipelmc/plenario/ojs/notes.js"
pal = palette()
viewof n = Inputs.range([10, 500], {value: 50, step: 10, label: "tamanho da amostra"})
medias = {
const r = rng(42);
return Array.from({length: 1000}, () => mean(Array.from({length: n}, () => r.normal())));
}
Plot.plot({
style: plotStyle, height: 360, width: 1000, marginBottom: 50,
x: {domain: [-1, 1], label: "média amostral"}, y: {label: "frequência"},
marks: [
Plot.rectY(medias, Plot.binX({y: "count"}, {x: d => d, fill: pal.accent, thresholds: 40})),
Plot.ruleY([0], {stroke: pal.lineStrong})
]
})