nx_qc_spc.nx
buildroot/runtime/nx_qc_spc.nx
about
nx_qc_spc.nx -- FOOD-SCIENCE SUITE / QUALITY CONTROL rung. Statistical
process control for a production line: Shewhart X-bar / R control charts,
process capability (Cp / Cpk), and proximate-analysis conservation +
Kjeldahl protein. Turns "looks fine" into a measured, in-/out-of-control
verdict and a capability index.
INTEGER-EXACT via the range method: sigma is estimated as Rbar/d2 using
the tabulated Shewhart constants (x1000), so NO square root is needed.
Control limits carried in milli-units for precision; Cp/Cpk x1000.
X-bar: UCL/LCL = Xbarbar +/- A2 * Rbar
R: UCL = D4 * Rbar, LCL = D3 * Rbar
Cp = (USL-LSL)/(6 sigma), sigma = Rbar/d2
Cpk = min(USL-mean, mean-LSL)/(3 sigma) (capable if Cpk >= 1.33)
THE exceed: an out-of-control point and a capability index are COMPUTED
from the subgroup ranges, not eyeballed; and proximate composition is
conserved to 100% by construction.
grounded: shewhart_control_charts + astm_process_capability_cpk
+ kjeldahl_nitrogen_to_protein_6.25
genealogy_id: statistical_process_control + nishi_food_science_suite
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_qc_spc_test.nx
structs
| none |
consts
| 25 | const QC_MAGIC_2282: i64 = 2282 |
| 26 | const QC_MAGIC_2114: i64 = 2114 |
| 27 | const QC_MAGIC_2059: i64 = 2059 |
| 28 | const QC_MAGIC_2326: i64 = 2326 |
| 30 | const QC_CAPABLE_CPK_MILLI: i64 = 1330 // Cpk >= 1.33 = capable |
| 31 | const QC_KJELDAHL_FACTOR_X100: i64 = 625 // general N->protein factor 6.25 |
functions
| 35 | func qc_a2(n: i64) -> i64 called by 1: main |
| 40 | func qc_d3(n: i64) -> i64 |
| 43 | func qc_d4(n: i64) -> i64 called by 1: main |
| 48 | func qc_d2(n: i64) -> i64 called by 1: main |
| 56 | func qc_xbar_ucl_milli(xbarbar: i64, a2: i64, rbar: i64) -> i64 called by 1: main |
| 59 | func qc_xbar_lcl_milli(xbarbar: i64, a2: i64, rbar: i64) -> i64 called by 1: main |
| 64 | func qc_in_control(x: i64, ucl_milli: i64, lcl_milli: i64) -> i64 called by 1: main |
| 71 | func qc_r_ucl_milli(d4: i64, rbar: i64) -> i64 called by 1: main |
| 77 | func qc_cp_milli(usl: i64, lsl: i64, d2: i64, rbar: i64) -> i64 called by 1: main |
| 82 | func qc_cpk_milli(usl: i64, lsl: i64, mean: i64, d2: i64, rbar: i64) -> i64 called by 1: main |
| 90 | func qc_is_capable(cpk_milli: i64) -> i64 called by 1: main |
| 98 | func qc_carb_by_difference(moist: i64, protein: i64, fat: i64, ash: i64) -> i64 called by 1: main |
| 103 | func qc_proximate_conserves(moist: i64, protein: i64, fat: i64, ash: i64, carb: i64) -> i64 called by 1: main |
| 109 | func qc_protein_from_nitrogen(nitrogen_x10: i64) -> i64 called by 1: main |