code wiki / (root) / nx_survey_stats.nx

nx_survey_stats.nx

buildroot/runtime/nx_survey_stats.nx

16805 B431 linesdepth 9pulls 10 transitivereach 8 importersview sourcekind librarytopic survey
docsdependenciesstructsconstsfunctions

about

nx_survey_stats.nx -- the INSIGHTS engine over survey responses (operator 2026-07-10: "we have the survey front end but we dont have any of the statistics or all the capabilities that power meaningful insights"). CONSUMES nx_survey_engine's effective ballots (se_ballots -> vout[i]/lout[i] = ballot record bytes) and question records; turns raw responses into the analytics a real survey product delivers: - descriptive: n/min/max/mean/median/mode/stddev (fixed-point permille, integer isqrt) - CX metrics: NPS (promoters-detractors), top/bottom-box, 95% confidence margin on a proportion - cross-tabulation: r x c contingency of one question by another - significance: chi-square test of independence vs a DATA-DRIVEN critical table (alpha .05), FAIL-CLOSED past df 10 (never a false "significant") -- the adversary's own guard - key drivers: Pearson correlation of every scale question against a chosen outcome, ranked by |r| - segment analysis: mean of a target question within each level of a segment question - trend: before/after split on real ballot timestamps - welfare triage rollup: composes nx_survey's sv_triage/sv_band to count crisis/strained/stable - open text: sovereign tokenized theme frequency (honest: frequency-based, NOT neural topic/sentiment) 100% integer / fixed-point, no floats, no hardware writes. Every stat is hand-KAT'd in the gate and carries an adversarial neg-control (a fabricated significance / correlation must be rejected). license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_survey_engine.nx nx_survey_stats.nx nx_survey_quality.nx nx_survey_stats_gate.nx

imports: nx_survey_engine.nx

imported by: nx_survey_quality.nxnx_survey_stats_gate.nx

structs

none

consts

18const ST_MAGIC_3841: i64 = 3841
19const ST_MAGIC_5991: i64 = 5991
20const ST_MAGIC_7815: i64 = 7815
21const ST_MAGIC_9488: i64 = 9488
22const ST_MAGIC_11070: i64 = 11070
23const ST_MAGIC_12592: i64 = 12592
24const ST_MAGIC_14067: i64 = 14067
25const ST_MAGIC_15507: i64 = 15507
26const ST_MAGIC_16919: i64 = 16919
27const ST_MAGIC_18307: i64 = 18307
28const ST_MAGIC_9223372036854775807: i64 = 9223372036854775807
29const ST_MAGIC_4096: i64 = 4096
31const ST_SCALE: i64 = 1000 // permille fixed-point
32const ST_Z95SQ: i64 = 3841600 // (1.96 * 1000)^2 = 3841600, the 95% two-tailed z^2 in permille^2

functions

35func st_isqrt(n: i64) -> i64
45func st_answer_int(vp: *u8, vl: i64, qid: *u8) -> i64
53func st_ballot_usec(vp: *u8, vl: i64) -> i64
called by 1: st_trend_split calls 2: canon_decodesv_get
63func st_collect(vout: *i64, lout: *i64, nb: i64, qid: *u8, xs: *i64) -> i64
called by 1: sv2_results calls 1: st_answer_int
74func st_collect_pairs(vout: *i64, lout: *i64, nb: i64, qx: *u8, qy: *u8, xs: *i64, ys: *i64) -> i64
called by 2: sv2_ins_driversmain calls 1: st_answer_int
86func st_sortcopy(xs: *i64, m: i64, dst: *i64) -> i64
called by 1: st_desc
105func st_desc(xs: *i64, m: i64, out: *i64) -> i64
called by 2: sv2_resultsmain calls 2: st_sortcopyst_isqrt
145func st_nps(xs: *i64, m: i64, prom_min: i64, det_max: i64, out: *i64) -> i64
called by 2: sv2_resultsmain
160func st_topbox(xs: *i64, m: i64, maxval: i64, boxsize: i64) -> i64
called by 2: sv2_resultsmain
169func st_ci_margin(k: i64, n: i64) -> i64
called by 2: sv2_resultsmain calls 1: st_isqrt
180func st_xtab(vout: *i64, lout: *i64, nb: i64, qa: *u8, qb: *u8, ra: i64, cb: i64, table: *i64) -> i64
called by 1: main calls 1: st_answer_int
198func st_crit05_pm(df: i64) -> i64
called by 2: st_chisqmain
212func st_chisq(table: *i64, r: i64, c: i64, out: *i64) -> i64
called by 1: main calls 1: st_crit05_pm
255func st_corr(xs: *i64, ys: *i64, m: i64) -> i64
called by 2: sv2_ins_driversmain calls 1: st_isqrt
284func st_segment_means(vout: *i64, lout: *i64, nb: i64, seg_qid: *u8, tgt_qid: *u8, seg_n: i64, out_n: *i64, out_meanpm: *i64) -> i64
called by 1: main calls 1: st_answer_int
306func st_trend_split(vout: *i64, lout: *i64, nb: i64, qid: *u8, split_usec: i64, out: *i64) -> i64
called by 1: main calls 2: st_answer_intst_ballot_usec
335func st_triage_rollup(vout: *i64, lout: *i64, nb: i64, wqids: *i64, weights: *i64, nw: i64, t_str: i64, t_cri: i64, out: *i64) -> i64
called by 1: main calls 3: canon_decodesv_triagesv_band
356func st_stopword(t: *u8) -> i64
called by 1: st_text_themes calls 1: se_seq
381func st_text_themes(vout: *i64, lout: *i64, nb: i64, qid: *u8, terms_out: *i64, freq_out: *i64, cap: i64) -> i64
424func st_term_freq(vout: *i64, lout: *i64, nb: i64, qid: *u8, term: *u8) -> i64
called by 1: main calls 2: st_text_themesse_seq