Published
Edited
Sep 23, 2021
Importers
Insert cell
Insert cell
viewof zscoreTable = {
const out = [];
const loop = (start, end, zDisplay, zFn) => {
for (let row = start; row <= end; row += 0.1){
const obj = { z: zDisplay(row) };

for (let col = 0.00; col <= 0.09; col += .01){
obj[col.toFixed(2)] = normalcdf(zFn(row, col)).toFixed(4);
}

out.push(obj);
}
}

loop(-3.4, 0.1, row => `-${Math.abs(row).toFixed(1)}`, (row, col) => row - col);
loop(0, 3.5, row => row.toFixed(1), (row, col) => row + col);
return Inputs.table(out, { height: 550 });
}
Insert cell
zscoreTable
Insert cell
// https://www.math.ucla.edu/~tom/distributions/normal.html?
// From Hastings (1955), Approximations for Digital Computers
function normalcdf(x, mean = 0, std = 1) {
const z = (x - mean) / std,
t = 1 / (1 + .2316419 * Math.abs(z)),
prob = .3989423 * Math.exp(-z * z / 2) * t * (.3193815 + t * ( -.3565638 + t * (1.781478 + t * (-1.821256 + t * 1.330274))));
return z > 0 ? 1 - prob : prob;
}
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