code wiki / (root) / nx_estimator_diagnostics.nx

nx_estimator_diagnostics.nx

buildroot/runtime/nx_estimator_diagnostics.nx

7171 B183 linesdepth 4pulls 4 transitivereach 3 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_estimator_diagnostics.nx -- substrate primitive for bias-variance decomposition of estimator outputs. THEORY (cited from first principles, NOT folklore): For an estimator T̂ of a true parameter θ, the Mean Squared Error decomposes as: MSE(T̂) = E[(T̂ - θ)²] = Var(T̂) + [Bias(T̂)]² where Bias(T̂) = E[T̂] - θ and Var(T̂) = E[(T̂ - E[T̂])²]. Source: Lehmann & Casella, "Theory of Point Estimation" 2nd ed., Springer 1998, eqs. 1.5.1, 1.5.2. Same decomposition appears in every statistics textbook (Casella-Berger §7.3, Wasserman §6.3). Interpretation for an HLL-vs-DS comparison: - If our mean_err > DS mean_err but our max_err < DS max_err, we have HIGHER BIAS but LOWER VARIANCE. The math says we should debias the estimator. Fix class: FX11 RecalibrateTable, or post-hoc bias correction term. - If our mean_err < DS mean_err but our max_err > DS max_err, we have LOWER BIAS but HIGHER VARIANCE. Add ensemble averaging (HIP estimator) or shrinkage. - If both worse: estimator class is fundamentally weaker; consider algorithm swap (FX02). Beyond the first two moments, we expose: - skewness: (third central moment) / sigma³ -- detects asymmetric error - excess kurtosis: (fourth central moment) / sigma⁴ - 3 -- detects heavy tails (matters for max-error comparison) All computed in i64 fixed-point at PPB (parts per billion) precision. genealogy_id: lehmann_casella_1998 + pearson_skewness_1895 lineage_id: estimator_theory + moment_method

dependencies 2 imports · 3 importers

syscalls.nx nx_i128.nx nx_estimator_diagnostics.nx nx_estimator_diagnostics_test.nx nx_remedy.nx nx_remedy_test.nx

imports: syscalls.nxnx_i128.nx

imported by: nx_estimator_diagnostics_test.nxnx_remedy.nxnx_remedy_test.nx

structs

49struct EstimatorDiag

consts

46const NX_DIAG_PPB_SCALE: i64 = 1000000000
122const NX_DIAG_VERDICT_BOTH_WORSE: i64 = 0
123const NX_DIAG_VERDICT_BOTH_BETTER: i64 = 1
124const NX_DIAG_VERDICT_HIGHER_BIAS_LOWER_VAR: i64 = 2
125const NX_DIAG_VERDICT_LOWER_BIAS_HIGHER_VAR: i64 = 3
126const NX_DIAG_VERDICT_TIE: i64 = 4
169const NX_DIAG_FX_NO_ACTION: i64 = 0
170const NX_DIAG_FX_SWAP_ALGORITHM: i64 = 2 // FX02
171const NX_DIAG_FX_REFORMULATE: i64 = 6 // FX06
172const NX_DIAG_FX_UPGRADE_Q: i64 = 9 // FX09
173const NX_DIAG_FX_RECALIBRATE: i64 = 11 // FX11
175const NX_DIAG_FX_ENSEMBLE: i64 = 13 // FX13 (new class)

functions

59func nx_diag_alloc() -> *EstimatorDiag
called by 2: mainmain
79func nx_diag_compute(d: *EstimatorDiag, estimates: *i64, n: i64, theta: i64) -> i64
called by 1: main calls 1: nx_muldiv_i64
128func nx_diag_compare(ours: *EstimatorDiag, theirs: *EstimatorDiag) -> i64
177func nx_diag_recommend(verdict: i64) -> i64
called by 1: main