Skip to content

Latest commit

 

History

History

factor_race.mjs — the factor calibration core in JavaScript

A dependency-free ES-module port of winning.factor.core (Python canonical), for browser demos and Node. Min-wins convention.

  • logndtr(z) — tail-stable normal log-CDF (series + continued fraction), matches scipy.special.log_ndtr to ~2e-13 over z in [-40, 8].
  • Both transforms take opts.base: "normal" (default) or "gumbel" (standardized Gumbel-min, so the independent case is exactly Luce/softmax at inverse temperature pi/sqrt(6)); the inverse also takes opts.mu0 to warm-start the Newton iteration for interactive use. "skew" (skew-normal, alpha=3) and "t4" (Student-t, nu=4) are tabulated bases (~1e-6 accuracy, vectors in test_vectors_bases.json). Gumbel parity vectors live in test_vectors_gumbel.json (gen_test_vectors_gumbel.py).
  • winProbabilitiesFactor(mu, V, D, F, W, opts) — all-share forward pass on the shared survival field; options pairwise (photo-finish tie densities w_ij, the circuit conductances), deletions (the full single-removal ensemble), points (lattice size, default 501). Also returns per-coordinate own-slopes.
  • abilitiesFromProbabilitiesFactor(p, V, D, F, W, opts) — share calibration by warm-started damped coordinatewise Newton, mirroring the Python implementation line for line.

Parity: node test_parity.mjs checks against test_vectors.json, generated by gen_test_vectors.py from the canonical implementation (seeded). Current agreement: forward shares 4e-16, pairwise densities 9e-16, deletion ensemble 1e-16, calibrated abilities 1e-15 vs Python.

Language matrix: Python (winning.factor, canonical), Rust (rust/fastrace, compiled kernel), R (r/, pure-R package), JavaScript (this directory). Julia: planned.

Hermite nodes ship inside test_vectors.json for the test problem; browser demos should embed nodes exported from winning.factor.hermite_nodes the same way.