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

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