Skip to content

src/core/stats.js ​

Small numerical toolbox: seeded RNG, normal distribution helpers, weighted summaries. No dependencies.

Import: import { … } from './src/core/stats.js' — no DOM, runs in Node and the browser.

makeRng ​

js
function makeRng(seed = 1)

Seeded generator (sfc32). next() is uniform in [0,1) with 53-bit resolution.

ndtri ​

js
function ndtri(p)

Inverse of the standard normal CDF (Acklam; relative error ~1e-9).

erfc ​

js
function erfc(x)

Complementary error function (fractional error < 1.2e-7).

normCdf ​

js
const normCdf

No description in the source.

logAddExp ​

js
function logAddExp(a, b)

No description in the source.

weightedQuantiles ​

js
function weightedQuantiles(x, w, qs)

Weighted quantiles of x (weights need not be normalised).

weightedMeanStd ​

js
function weightedMeanStd(x, w)

No description in the source.

resampleIndices ​

js
function resampleIndices(w, n, rng)

Systematic resampling: indices of n equally weighted draws.

ksUniformP ​

js
function ksUniformP(v)

Kolmogorov-Smirnov p-value that values in [0,1) are uniform.

MIT licensed · Kyle A. Pearson