UNPKG

@railpath/finance-toolkit

Version:

Production-ready finance library for portfolio construction, risk analytics, quantitative metrics, and ML-based regime detection

14 lines (13 loc) 400 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.inverseErf = inverseErf; /** * Inverse error function approximation */ function inverseErf(x) { const a = 0.147; const b = 2 / (Math.PI * a) + Math.log(1 - x * x) / 2; const sqrt1 = Math.sqrt(b * b - Math.log(1 - x * x) / a); const sqrt2 = Math.sqrt(sqrt1 - b); return sqrt2 * Math.sign(x); }