export function roundToSignificantFigures(num: number, sig: number): number { if (num === 0) return 0; const magnitude = Math.floor(Math.log10(Math.abs(num))); const factor = Math.pow(10, sig - magnitude - 1); return Math.round(num * factor) / factor; } export function calcBayesFactorFromPartialMatchWeight(omega: number): number { return Math.pow(2, omega); } export function calcProbabilityFromPartialMatchWeight(omega: number): number { const bf = calcBayesFactorFromPartialMatchWeight(omega); return bf / (1 + bf); } export function calcBayesFactorFromProbability(p: number): number { return p / (1 - p); } export function calcPartialMatchWeightFromBayesFactor(bf: number): number { return Math.log2(bf); } export function calcPartialMatchWeightFromProbability(p: number): number { const bf = calcBayesFactorFromProbability(p); return calcPartialMatchWeightFromBayesFactor(bf); } export function calcProbabilityFromPartialMatchWeightInverse( omega: number ): number { const bf = calcBayesFactorFromPartialMatchWeight(omega); return 1 / (1 + 1 / bf); } export function calcBayesFactorFromMandU(m: number, u: number): number { return m / u; }