Published
Edited
Oct 20, 2021
Importers
Insert cell
# Statistical Functions
Insert cell
runif = (min, max) => min + (max - min) * Math.random()
Insert cell
rbernoulli = (p) => (Math.random() < p ? 1 : 0);
Insert cell
// Adapted from https://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve
rnorm = (mean, sd) => {
var u = 0, v = 0;
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
while(v === 0) v = Math.random();
return mean + sd * (Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ));
}
Insert cell
inv_logit = (x) => Math.exp(x)/(1+Math.exp(x))
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