code wiki / (root) / nx_survey_stats.nx

nx_survey_stats.nx

buildroot/runtime/nx_survey_stats.nx

16686 B425 linesdepth 9pulls 12 transitivereach 9 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 2 imports · 3 importers

nx_survey_engine.nx nx_vecmath.nx nx_survey_stats.nx nx_communitypulse.nx nx_survey_quality.nx nx_survey_stats_gate.nx

imports: nx_survey_engine.nxnx_vecmath.nx

imported by: nx_communitypulse.nxnx_survey_quality.nxnx_survey_stats_gate.nx

structs

none

consts

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

functions

36func st_isqrt(n: i64) -> i64 { return vm_isqrt(n) }
39func st_answer_int(vp: *u8, vl: i64, qid: *u8) -> i64
47func st_ballot_usec(vp: *u8, vl: i64) -> i64
57func st_collect(vout: *i64, lout: *i64, nb: i64, qid: *u8, xs: *i64) -> i64
68func 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
80func st_sortcopy(xs: *i64, m: i64, dst: *i64) -> i64
called by 1: st_desc
99func st_desc(xs: *i64, m: i64, out: *i64) -> i64
called by 2: sv2_resultsmain calls 2: st_sortcopyst_isqrt
139func st_nps(xs: *i64, m: i64, prom_min: i64, det_max: i64, out: *i64) -> i64
called by 2: sv2_resultsmain
154func st_topbox(xs: *i64, m: i64, maxval: i64, boxsize: i64) -> i64
called by 2: sv2_resultsmain
163func st_ci_margin(k: i64, n: i64) -> i64
called by 2: sv2_resultsmain calls 1: st_isqrt
174func 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
192func st_crit05_pm(df: i64) -> i64
called by 2: st_chisqmain
206func st_chisq(table: *i64, r: i64, c: i64, out: *i64) -> i64
called by 1: main calls 1: st_crit05_pm
249func st_corr(xs: *i64, ys: *i64, m: i64) -> i64
called by 2: sv2_ins_driversmain calls 1: st_isqrt
278func 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
300func st_trend_split(vout: *i64, lout: *i64, nb: i64, qid: *u8, split_usec: i64, out: *i64) -> i64
329func 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
350func st_stopword(t: *u8) -> i64
called by 1: st_text_themes calls 1: se_seq
375func st_text_themes(vout: *i64, lout: *i64, nb: i64, qid: *u8, terms_out: *i64, freq_out: *i64, cap: i64) -> i64
418func st_term_freq(vout: *i64, lout: *i64, nb: i64, qid: *u8, term: *u8) -> i64
called by 1: main calls 2: st_text_themesse_seq