code wiki / (root) / nx_calibration.nx

nx_calibration.nx

buildroot/runtime/nx_calibration.nx

12063 B335 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_calibration.nx -- statistical calibration of predicted confidences. When the substrate emits "predicted age 22 with 90% confidence" (or any probability claim), DOES 90% confidence empirically produce a hit 90% of the time? Without calibration, model confidences are opaque numbers users learn to ignore. With calibration, they become RELIABILITY-GUARANTEED measurements. References: Brier 1950 "Verification of Forecasts Expressed in Terms of Probability" -- the Brier score BS = (1/N) * sum_i (p_i - o_i)^2 where p_i in [0,1] is forecast probability and o_i in {0,1}. Naeini/Cooper/Hauskrecht 2015 "Obtaining Well Calibrated Probabilities Using Bayesian Binning" -- ECE / MCE. DeGroot/Fienberg 1983 -- "well-calibrated" definition. Closes calibration field in nxc2/docs/TOPDOWN_BOTTOMUP_GAP_ANALYSIS.md. No existing image- gen / LLM stack measures calibration of its OWN confidences in a bits-up form; "confidence" floats around with no empirical anchor. genealogy_id: brier_1950_naeini_2015 lineage_id: substrate_calibration_v1 5W+H+GLP linkage: emits VERDICT records with what=VERDICT, how=brier|ece|mce, performance=score_q10.

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_runtime.nx nx_tier.nx nx_calibration.nx

imports: nx_syscalls.nxnx_runtime.nxnx_tier.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nx_cal_report sys_mmap ↻ nx_cal_bin _cal_bin_idx nx_cal_brier_q10 nx_cal_ece_q10 nx_cal_mce_q10 nx_cal_verdict_from_ece nx_cal_verdict_from_ece ↻ _cal_bin_idx ↻ nx_cal_brier_q10 ↻

structs

76struct NxCalibrationResult

consts

39const NX_MAGIC_1024: i64 = 1024
43const NX_CAL_Q10: nx_int = 1024
47const NX_CAL_MAX_SAMPLES: nx_int = 1048576
48const NX_CAL_MAX_BINS: nx_int = 100
49const NX_CAL_DEFAULT_BINS: nx_int = 10
55const NX_CAL_VERDICT_EXCELLENT: nx_int = 0 // ECE < 0.02
56const NX_CAL_VERDICT_GOOD: nx_int = 1 // ECE < 0.05
57const NX_CAL_VERDICT_FAIR: nx_int = 2 // ECE < 0.10
58const NX_CAL_VERDICT_POOR: nx_int = 3 // ECE < 0.20
59const NX_CAL_VERDICT_BROKEN: nx_int = 4 // ECE >= 0.20
61const NX_CAL_THR_EXCELLENT_Q10: nx_int = 20 // 0.02 * 1024
62const NX_CAL_THR_GOOD_Q10: nx_int = 51 // 0.05 * 1024
63const NX_CAL_THR_FAIR_Q10: nx_int = 102 // 0.10 * 1024
64const NX_CAL_THR_POOR_Q10: nx_int = 204 // 0.20 * 1024
88const NX_CAL_RESULT_BYTES: nx_size = 72

functions

66func nx_cal_verdict_from_ece(ece_q10: nx_int) -> nx_int
called by 2: nx_cal_reportmain
100func nx_cal_brier_q10(p_q10: *nx_int, o: *nx_int, n_samples: nx_int) -> nx_int
called by 2: nx_cal_reportmain
121func _cal_bin_idx(p_q10: nx_int, n_bins: nx_int) -> nx_int
called by 2: nx_cal_binmain
136func nx_cal_bin(
called by 1: nx_cal_report calls 1: _cal_bin_idx
184func nx_cal_ece_q10(
called by 1: nx_cal_report
208func nx_cal_mce_q10(
called by 1: nx_cal_report
227func nx_cal_report(
270func main() -> nx_int