Published
Edited
Aug 25, 2019
1 fork
Importers
1 star
Also listed in…
Statistics
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Generate n samples from standard normal distribution
function boxMuller(n) {
const samples = [];
Array(Math.ceil(n / 2)).fill().forEach(_ => {
const R = Math.sqrt(-2 * Math.log(Math.random()));
const theta = 2 * Math.PI * Math.random();
samples.push(R * Math.cos(theta)); // z1
samples.push(R * Math.sin(theta)); // z2
});
// if n is odd, drop the last element
return samples.slice(0, n);
}
Insert cell
Insert cell
normalSamples = boxMuller(10000)
Insert cell
import {chart as histogram} with {normalSamples as data} from "@d3/histogram"
Insert cell
Insert cell
Insert cell
import {chart as qqplot} with {normalSamples as data} from "@d3/normal-quantile-plot"
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