MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / expectApprox

Function expectApprox

test/compute-engine/monte-carlo.test.ts:9–21  ·  view source on GitHub ↗
(
  actual: number,
  expected: number,
  tolerance = TOL,
  absTolerance = ABS_TOL
)

Source from the content-addressed store, hash-verified

7// estimator, never sampling luck. Unseeded, the heavy-tailed semi-infinite
8// cases could red-flag any commit's gate at random (observed 2026-08-17:
9// ∫_1^∞ 1/x² dx off by 0.63 once, then 3 consecutive passes).
10//
11// The tolerances still reflect the estimator's statistical accuracy at the
12// pinned seeds — with n=1e6, standard error is typically ~1e-3 for
13// well-behaved integrands — so they stay meaningful if a seed changes.
14const N = 1e6;
15const TOL = 0.05; // 5% relative tolerance for most tests
16const ABS_TOL = 0.1; // absolute tolerance for values near zero
17
18/** A deterministic uniform-[0,1) stream, seeded per test by a tag string. */
19function seededDraw(tag: string): () => number {
20 const [lo, hi] = foldSeed(tag);
21 let n = 0;
22 return () => frameDraw(lo, hi, n++);
23}
24

Callers 1

Calls 1

absMethod · 0.65

Tested by

no test coverage detected