- X-bar and R control chart limits
- Cp and Cpk of a turning process
- t-test of a filling machine
- Operating characteristic of a sampling plan
- Pareto chart of PCB defects with DPMO and sigma level
- Parts per million out of tolerance with the error function
- Gauge linearity and bias study from the lab database
- c chart of paint defects per car body
- Two suppliers' surface roughness: Mann-Whitney test
- MTTF, B10 life and reliability of a bearing (Weibull)
- Detect the drift of a filling line with CUSUM
- Calibration line robust to a bad measure
- Alarm episodes that announce a stop
- Readable rules of the defects
- Inspection driven by the cost of errors
- Defect counts with overdispersion
- Failure rate of a new supplier
- Filling line: control chart, small shift and capability
- Is the caliper good enough? Gage R&R study
- Production line: system reliability, critical component and preventive replacement
X-bar and R control chart limits
Six subgroups of five diameters are measured on a lathe. The script computes the mean and range of each subgroup, then the control limits of the X-bar and R charts.
#1. 6 subgroups of 5 diameters in mm; json load "rx_q_sub" "[[10.02, 9.98, 10.01, 10.00, 9.99], [10.03, 10.01, 9.97, 10.02, 10.00], [9.99, 10.00, 10.02, 9.98, 10.01], [10.01, 10.04, 10.00, 10.02, 10.03], [9.98, 9.99, 10.01, 10.00, 9.97], [10.00, 10.02, 9.99, 10.01, 10.00]]"; #2. Mean and range of each subgroup; -> "[means]" "["; -> "[ranges]" "["; -> "[sep]" ""; json parse_array "rx_q_sub" "/" "[g]" { -> "[means]" (concat [means] [sep] (stat mean [g])); -> "[ranges]" (concat [ranges] [sep] (stat range [g])); -> "[sep]" ","; }; -> "[xbb]" (stat mean (concat [means] "]")); -> "[rb]" (stat mean (concat [ranges] "]")); #3. Control limits with A2 = 0.577 and D4 = 2.114 for n = 5; concat "X-bar chart: CL = " (math round [xbb] 4) ", UCL = " (math round (math calc "[xbb]+0.577*[rb]") 4) ", LCL = " (math round (math calc "[xbb]-0.577*[rb]") 4) " ; R chart: CL = " (math round [rb] 4) ", UCL = " (math round (math calc "2.114*[rb]") 4) ", LCL = 0"
X-bar chart: CL = 10.0033, UCL = 10.0274, LCL = 9.9793 ; R chart: CL = 0.0417, UCL = 0.0881, LCL = 0
- Flag the subgroups outside the limits with
ifin the loop - Estimate sigma as R-bar / d2 with d2 = 2.326
- Apply the Western Electric rules on the series of means
Cp and Cpk of a turning process
A shaft diameter has a tolerance of 25.00 +- 0.05 mm. The script checks the normality of 20 parts, computes Cp and Cpk and the expected nonconforming parts per million.
#1. Shaft diameter, spec 25.00 +- 0.05 mm, 20 parts; -> "[x]" "[25.012, 24.991, 25.004, 25.018, 24.987, 25.009, 24.998, 25.021, 25.003, 24.994, 25.011, 25.006, 24.983, 25.015, 25.000, 24.996, 25.008, 25.013, 24.989, 25.002]"; -> "[lsl]" 24.95; -> "[usl]" 25.05; -> "[m]" (stat mean [x]); -> "[s]" (stat stddev [x]); #2. Normality check, required before Cp and Cpk; json load "rx_q_sw" (stat shapiro [x]); #3. Capability indices and expected nonconforming parts per million; -> "[cp]" (math calc "([usl]-[lsl])/(6*[s])"); -> "[cpk]" (math calc "min([usl]-[m], [m]-[lsl])/(3*[s])"); -> "[ppm]" (math calc (concat "1e6*(" (stat dist_cdf "normal" (concat "[" [m] ", " [s] "]") [lsl]) " + 1 - " (stat dist_cdf "normal" (concat "[" [m] ", " [s] "]") [usl]) ")")); concat "Shapiro p = " (math round (json select "rx_q_sw" /p_value) 3) ", mean = " (math round [m] 4) ", s = " (math round [s] 4) ", Cp = " (math round [cp] 2) ", Cpk = " (math round [cpk] 2) ", expected " (math round_sig [ppm] 2) " ppm"
Shapiro p = 0.926, mean = 25.003, s = 0.0107, Cp = 1.56, Cpk = 1.47, expected 5.8 ppm
- Give a confidence interval on Cpk for 20 parts
- Use
stat percentile0.135 and 99.865 for a non-normal process - Compare two machines with
stat ttest_2
t-test of a filling machine
After a setting change, 12 bottles are weighed against a 500 g target. The script tests whether the mean is off target and gives the 95 % confidence interval of the mean.
#1. Filling machine, target 500 g, 12 bottles weighed after a setting change; -> "[w]" "[501.2, 499.8, 502.1, 500.9, 501.5, 500.4, 502.3, 501.1, 499.9, 501.8, 500.7, 501.6]"; #2. One-sample t-test, H0: mean = 500 g; json load "rx_q_t" (stat ttest_1 [w] 500); #3. 95 percent confidence interval of the true mean; json load "rx_q_ci" (stat conf_interval_mean [w] 0.95); -> "[p]" (json select "rx_q_t" /p_value); concat "t = " (math round (json select "rx_q_t" /t) 2) ", p = " (math round_sig [p] 3) ", mean in [" (math round (json select "rx_q_ci" /lower) 2) ", " (math round (json select "rx_q_ci" /upper) 2) "] g -> " (if (< [p] 0.05) {"machine off target, adjust the setting"} {"no significant shift"})
t = 4.76, p = 0.000594, mean in [500.6, 501.62] g -> machine off target, adjust the setting
- Compare before and after maintenance with
stat ttest_2 - Use
stat ztestwhen the machine sigma is known - Check the legal mean requirement of prepackages
Operating characteristic of a sampling plan
Single sampling plan n = 50, c = 2: the probability of accepting a lot is a binomial tail, written with the regularized incomplete beta function. The script gives the acceptance at AQL 1 %, the producer risk, the LTPD (10 % acceptance) and the probability of a sample with no defective.
#1. Single sampling plan: sample n = 50, accept the lot if at most c = 2 defectives; -> "[n]" 50; -> "[c]" 2; #2. Operating characteristic: Pa of p = P of X <= c = I_1-p of n-c, c+1, regularized incomplete beta; -> "[Pa1]" (math calc "beta_inc([n]-[c], [c]+1, 1-0.01)"); #3. LTPD: defect rate accepted only 10 % of the time; -> "[ltpd]" (num solve "beta_inc(48, 3, 1-p)-0.10" "p" 0.01 0.3); #4. Probability of exactly 0 defective at 1 %, with the beta function; -> "[P0]" (math calc "1/(([n]+1)*beta([n]+1, 1))*0.99^[n]"); concat "Pa at AQL 1 % = " (math round [Pa1] 4) ", producer risk = " (math round (math calc "1-[Pa1]") 4) ", LTPD = " (math round (math calc "100*[ltpd]") 2) " %, P of no defective at 1 % = " (math round [P0] 4)
Pa at AQL 1 % = 0.9862, producer risk = 0.0138, LTPD = 10.3 %, P of no defective at 1 % = 0.605
- Draw the OC curve with
plot function "beta_inc(48, 3, 1-p)" "p" 0 0.15. - Search the smallest n meeting both risks with a
forloop.
Pareto chart of PCB defects with DPMO and sigma level
118 defects were found on 1200 printed circuit boards with 85 opportunities each. Sort the causes by decreasing count, build the bars and the cumulative percentage line of the Pareto chart, and put the DPMO and the short-term sigma level (with the 1.5 sigma shift) in its title.
#1. Defects found on 1200 printed circuit boards, 85 opportunities per board; json load "rx_def" "[{\"cause\": \"solder bridge\", \"n\": 46}, {\"cause\": \"missing part\", \"n\": 12}, {\"cause\": \"cold joint\", \"n\": 31}, {\"cause\": \"wrong polarity\", \"n\": 7}, {\"cause\": \"tombstoning\", \"n\": 18}, {\"cause\": \"scratch\", \"n\": 4}]"; #2. Pareto order: sort the causes by decreasing count; json sort "rx_def" / n DESC; -> "[total]" 0; for (-> "[i]" 0) (< [i] (json count "rx_def" /)) (++ "[i]") {-> "[total]" (+ [total] (json select "rx_def" (concat "/[" [i] "]/n")));}; #3. Bars of the counts and the cumulative percentage line; -> "[names]" "["; -> "[bars]" "["; -> "[cum]" "["; -> "[c]" 0; for (-> "[i]" 0) (< [i] (json count "rx_def" /)) (++ "[i]") { -> "[sep]" (if (> [i] 0) {", "} {""}); -> "[c]" (+ [c] (json select "rx_def" (concat "/[" [i] "]/n"))); -> "[names]" (concat [names] [sep] (+ [i] 1)); -> "[bars]" (concat [bars] [sep] (json select "rx_def" (concat "/[" [i] "]/n"))); -> "[cum]" (concat [cum] [sep] (math round (* 100 (/ [c] [total])) 1)); }; #4. DPMO and short-term sigma level with the 1.5 sigma shift; -> "[dpmo]" (math round (math calc "[total]/(1200*85)*1e6") 0); -> "[sigma]" (math round (+ (stat dist_inv "normal" "[0, 1]" (- 1 (/ [dpmo] 1e6))) 1.5) 2); -> "[title]" (concat "Pareto of defects - first: " (json select "rx_def" "/[0]/cause") " - DPMO " [dpmo] " - sigma level " [sigma]); plot chart (concat "{\"title\": \"" [title] "\", \"x_label\": \"cause rank\", \"y_label\": \"defects / cumulative pct\", \"series\": [{\"name\": \"defects\", \"type\": \"bars\", \"x\": " [names] "], \"y\": " [bars] "]}, {\"name\": \"cumulative pct\", \"type\": \"line\", \"x\": " [names] "], \"y\": " [cum] "]}]}")
The chart is shown in the Plot tab of the editor.
- Keep the vital few: the causes before 80 pct of the cumulative line.
- Follow the defect rate per day with a p chart (limits p +- 3 sqrt of p (1-p) / n).
Parts per million out of tolerance with the error function
A shaft is specified at 25 +- 0.015 mm; the process runs at a mean of 25.004 mm with sigma 0.006 mm. The script computes the fraction above and below the limits with erfc, the total ppm, Cpk and the sigma that would be needed for the six sigma target of 3.4 ppm on the nearest limit.
#1. Specification and process; -> "[usl]" 25.015; -> "[lsl]" 24.985; -> "[mu]" 25.004; -> "[sd]" 0.006; #2. Tails of the normal law with erfc; -> "[pu]" (* 0.5 (math erfc (/ (- [usl] [mu]) (* [sd] (math sqrt 2))))); -> "[pl]" (* 0.5 (math erfc (/ (- [mu] [lsl]) (* [sd] (math sqrt 2))))); -> "[cpk]" (/ (math min (- [usl] [mu]) (- [mu] [lsl])) (* 3 [sd])); #3. z for 3.4 ppm on one side, and the sigma it requires; -> "[z]" (* (math sqrt 2) (math erf_inv (- 1 (* 2 0.0000034)))); concat "above USL: " (math round (* 1000000 [pu]) 0) " ppm, below LSL: " (math round (* 1000000 [pl]) 1) " ppm, total: " (math round (* 1000000 (+ [pu] [pl])) 0) " ppm" [_n_] "Cpk = " (math round [cpk] 3) [_n_] "3.4 ppm needs z = " (math round [z] 3) ", so sigma <= " (math round (/ (- [usl] [mu]) [z]) 5) " mm with this mean"
above USL: 33377 ppm, below LSL: 771 ppm, total: 34147 ppm Cpk = 0.611 3.4 ppm needs z = 4.5, so sigma <= 0.00244 mm with this mean
- Center the process first: compute the ppm with mu = 25.000.
- Compare with
stat dist_cdfon the normal law.
Gauge linearity and bias study from the lab database
Reference parts of 2 to 10 mm were measured with a caliper and the readings stored in the laboratory database (an embedded H2 database here). The script loads the bias versus reference directly from SQL into a linear regression and reports the AIAG linearity, the bias and the significance of the slope.
#1. Lab database: embedded H2 file under tmp; cm set "tuto_p4g_lab" {execute "db.h2.embedded.config.get" "[database]" "./tmp/tuto_p4g_lab/msa" "[user]" "tuto" "[password]" "tuto_pwd" ;}; sql connect "tuto_p4g_s1" {cm get "tuto_p4g_lab";}; sql dml "tuto_p4g_s1" "create table caliper (ref double, bias double)"; sql dml "tuto_p4g_s1" "insert into caliper values (2, 0.012), (2, 0.010), (4, 0.006), (4, 0.008), (6, 0.001), (6, -0.002), (8, -0.006), (8, -0.004), (10, -0.011), (10, -0.013)"; sql disconnect "tuto_p4g_s1"; #2. Regression bias = a + b . reference straight from the query; pa rl load "rx_p4g_lin" "tuto_p4g_lab" "ref" "bias" "select ref, bias from caliper"; #3. AIAG: linearity = abs slope x process variation 0.6 mm; -> "[b]" (pa rl slope "rx_p4g_lin"); -> "[r]" (concat "n = " (pa rl count "rx_p4g_lin") ", bias = " (math round (pa rl intercept "rx_p4g_lin") 4) " " (math round [b] 5) " x ref, r2 = " (math round (pa rl r_square "rx_p4g_lin") 4) ", slope p-value " (if (< (pa rl significance "rx_p4g_lin") 0.001) {"< 0.001";} {pa rl significance "rx_p4g_lin";}) [_n_] "linearity = " (math round (* (math abs [b]) 0.6) 5) " mm, %linearity = " (math round (* 100 (math abs [b])) 2) " %, bias at 6 mm = " (math round (* 1000 (pa rl predict "rx_p4g_lin" 6)) 2) " um"); #4. Close and remove the temporary database; pa rl close "rx_p4g_lin"; cm remove "tuto_p4g_lab"; file delete "tmp/tuto_p4g_lab"; [r]
n = 10, bias = 0.0175 -0.0029 x ref, r2 = 0.9738, slope p-value < 0.001 linearity = 0.00174 mm, %linearity = 0.29 %, bias at 6 mm = 0.1 um
- Add a bias t-test per reference with
stat ttest_1. - Store the study result back in a table with
sql dml.
c chart of paint defects per car body
An inspector counted the paint defects on 20 consecutive car bodies. The script computes the centre line and the Poisson control limits of the c chart, the bodies out of control, the frequency table and the most frequent count.
#1. Defects per body, in production order; -> "[c]" "[3, 5, 2, 4, 6, 3, 2, 12, 4, 3, 5, 1, 4, 3, 2, 6, 4, 3, 5, 3]"; -> "[cb]" (math avg [c]); -> "[ucl]" (math calc "[cb]+3*sqrt([cb])"); -> "[lcl]" (math max 0 (math calc "[cb]-3*sqrt([cb])")); #2. Bodies above the UCL; json load "rx_p4g_c" [c]; -> "[ooc]" ""; for (-> "[i]" 0) (< [i] 20) (++ "[i]") { if (> (json select "rx_p4g_c" (concat "/[" [i] "]")) [ucl]) {-> "[ooc]" (concat [ooc] " #" (+ [i] 1));}; }; json unload "rx_p4g_c"; #3. Distribution of the counts; -> "[f]" (string regexp_replace (string regexp_replace (stat frequency [c]) "\{\"value\": ([0-9]+), \"count\": ([0-9]+)[^}]*\}" "$1:$2") "\s+" ""); concat "c-bar = " [cb] ", UCL = " (math round [ucl] 2) ", LCL = " [lcl] [_n_] "out of control: body" [ooc] [_n_] "sorted: " (math order_int [c]) [_n_] "mode: " (stat mode [c]) ", count:bodies = " [f]
c-bar = 4.0, UCL = 10, LCL = 0 out of control: body #8 sorted: [1,2,2,2,3,3,3,3,3,3,4,4,4,4,5,5,5,6,6,12] mode: [3], count:bodies = [1:1,2:3,3:6,4:4,5:3,6:2,12:1]
- Recompute the limits without body 8 once its cause is found.
- Use a u chart when the inspected area changes from body to body.
Two suppliers' surface roughness: Mann-Whitney test
Ra roughness values of turned parts from two suppliers are skewed, so the quality engineer uses the non-parametric Mann-Whitney U test instead of a t-test, and reports the medians and which supplier is smoother.
#1. Ra in micrometres; -> "[a]" "[0.82, 0.91, 0.78, 1.25, 0.88, 0.85, 1.60, 0.80, 0.95, 0.87]"; -> "[b]" "[1.05, 1.12, 0.98, 1.40, 1.09, 1.21, 0.99, 1.85, 1.15, 1.03]"; #2. Medians and test; -> "[ma]" (stat median [a]); -> "[mb]" (stat median [b]); json load "rx_p4g_mw" (stat mann_whitney [a] [b]); -> "[p]" (json select "rx_p4g_mw" /p_value); -> "[r]" (concat "U = " (json select "rx_p4g_mw" /u) ", p = " (math round_sig [p] 3) " (" (json select "rx_p4g_mw" /method) ")"); json unload "rx_p4g_mw"; #3. Direction and decision; -> "[best]" (if (== (math signum (- [mb] [ma])) 1) {"A";} {"B";}); concat "median A = " [ma] " um, median B = " [mb] " um" [_n_] [r] [_n_] (if (< [p] 0.05) {concat "significant: supplier " [best] " is smoother";} {"no significant difference";})
median A = 0.875 um, median B = 1.105 um U = 17, p = 0.0140 (asymptotic) significant: supplier A is smoother
- Check the skewness first with
stat skewnessandstat shapiro. - Add a third supplier with
stat kruskal.
MTTF, B10 life and reliability of a bearing (Weibull)
Life tests of a bearing gave a Weibull shape beta = 1.8 and a scale eta = 12000 h. The script computes the MTTF and the standard deviation with the Gamma function, the B10 life with log1p, and the reliability at the 5000 h warranty.
#1. Weibull parameters; -> "[beta]" 1.8; -> "[eta]" 12000; #2. Mean and standard deviation of the life; -> "[g1]" (math gamma (+ 1 (/ 1 [beta]))); -> "[g2]" (math gamma (+ 1 (/ 2 [beta]))); -> "[mttf]" (* [eta] [g1]); -> "[sd]" (* [eta] (math sqrt (- [g2] (math power [g1] 2)))); #3. B10: 10 % failed, ln 0.9 = log1p of -0.1; -> "[b10]" (* [eta] (math power (- 0 (math log1p -0.1)) (/ 1 [beta]))); #4. Reliability at the warranty time; -> "[R]" (math calc "exp(-(5000/[eta])^[beta])"); concat "MTTF = " (math round [mttf] 0) " h, sigma = " (math round [sd] 0) " h" [_n_] "B10 life = " (math round [b10] 0) " h" [_n_] "R at 5000 h = " (math round (* 100 [R]) 2) " %, expected returns per 1000 = " (math round (* 1000 (- 1 [R])) 0)
MTTF = 10671 h, sigma = 6135 h B10 life = 3437 h R at 5000 h = 81.32 %, expected returns per 1000 = 187
- Fit beta and eta from failure times with
pa rlon the Weibull plot. - Compute the conditional reliability of a bearing that already ran 3000 h.
Detect the drift of a filling line with CUSUM
Watch the filled volume of 20 bottles with a two-sided CUSUM against the 500 mL target and the known sigma of 0.2 mL, find when the line started to drift and compare the means before and after.
#1. Filled volume in mL, target 500; -> "[v]" "[500.2, 499.8, 500.1, 499.9, 500.3, 499.7, 500.0, 500.2, 499.9, 500.1, 500.9, 501.2, 501.0, 501.4, 501.1, 501.3, 501.5, 501.2, 501.6, 501.4]"; json load "rx_c" (ml ts cusum [v] 4 0.5 500 0.2); -> "[res]" (concat (json count "rx_c" "/changes") " alarms | mean of the 10 first " (stat mean "[500.2, 499.8, 500.1, 499.9, 500.3, 499.7, 500.0, 500.2, 499.9, 500.1]") " mL, of the 10 last " (stat mean "[500.9, 501.2, 501.0, 501.4, 501.1, 501.3, 501.5, 501.2, 501.6, 501.4]") " mL | first alarm at bottle " (+ 1 (json select "rx_c" "/changes/[0]/index")) " " (json select "rx_c" "/changes/[0]/direction")); json unload "rx_c"; [res]
9 alarms | mean of the 10 first 500.02 mL, of the 10 last 501.26 mL | first alarm at bottle 12 up
- The first up alarm is the moment to stop and adjust the line.
- Test the two periods with
stat ttest_2to quantify the shift.
Calibration line robust to a bad measure
Fit the calibration line of a sensor on 9 reference points where one measure is wrong, compare the ordinary least squares with the Huber and RANSAC robust regressions and flag the bad point.
#1. Reference value - sensor reading, the 6th reading is wrong; -> "[x]" "[[0], [10], [20], [30], [40], [50], [60], [70], [80]]"; -> "[y]" "[0.3, 10.1, 20.4, 30.2, 40.1, 62.0, 60.3, 70.2, 80.4]"; json load "rx_ols" (ml train "rx_ols" "linear" [x] [y]); json load "rx_hub" (ml train "rx_hub" "huber" [x] [y]); json load "rx_ran" (ml train "rx_ran" "ransac" [x] [y] "{\"residual_threshold\": 1, \"seed\": 1}"); -> "[res]" (concat "slope OLS " (math round (json select "rx_ols" "/coef/[0]") 4) " | Huber " (math round (json select "rx_hub" "/coef/[0]") 4) " | RANSAC " (math round (json select "rx_ran" "/coef/[0]") 4) " | inliers " (json select "rx_ran" "/inliers")); json unload "rx_ols"; json unload "rx_hub"; json unload "rx_ran"; ml model delete "rx_ols"; ml model delete "rx_hub"; ml model delete "rx_ran"; [res]
slope OLS 1.0205 | Huber 1.0014 | RANSAC 1.0009 | inliers [ 1, 1, 1, 1, 1, 0, 1, 1, 1 ]
- The weights key of the Huber model shows how much each point counts.
- Give a weight per point with
ml trainwls when the uncertainty differs between points.
Alarm episodes that announce a stop
Search the alarm log of a line for the episodes, groups of alarms in order within 4 minutes, that occur at least 3 times, and keep the ones that end with a STOP.
#1. Alarm log: minute, alarm code; -> "[log]" "[[1, \"T_HIGH\"], [2, \"VIB\"], [3, \"STOP\"], [10, \"T_HIGH\"], [11, \"VIB\"], [13, \"STOP\"], [20, \"VIB\"], [25, \"P_LOW\"], [30, \"T_HIGH\"], [31, \"VIB\"], [32, \"STOP\"], [40, \"P_LOW\"], [41, \"T_HIGH\"]]"; json load "rx_e" (ml assoc episodes [log] 3 4); -> "[res]" (concat (json select "rx_e" "/count") " frequent episodes | ending with STOP: "); for (-> "[i]" 0) (< [i] (json select "rx_e" "/count")) (++ "[i]") { -> "[p]" (concat "/episodes/[" [i] "]/episode"); -> "[n]" (json count "rx_e" [p]); if (and (> [n] 1) (equal (json select "rx_e" (concat [p] "/[" (- [n] 1) "]/[0]")) "STOP")) { -> "[ep]" ""; for (-> "[k]" 0) (< [k] [n]) (++ "[k]") {-> "[ep]" (concat [ep] (if (> [k] 0) {" > "} {""}) (json select "rx_e" (concat [p] "/[" [k] "]/[0]")));}; -> "[res]" (concat [res] [ep] " x" (json select "rx_e" (concat "/episodes/[" [i] "]/support")) "; "); }; }; json unload "rx_e"; [res]
7 frequent episodes | ending with STOP: T_HIGH > VIB > STOP x3; T_HIGH > STOP x3; VIB > STOP x3;
ml assoc sequence_rulesgives the confidence when the history is cut into one sequence per day or per batch.- Count the alarms in real time with
ml sketchto trigger the analysis.
Readable rules of the defects
Learn from 150 inspected parts (temperature, pressure, line speed) the if-then rules that lead to a defect with RIPPER, and compare them with OneR, the best single variable.
#1. Parts: temperature in C, pressure in bar, speed in m/min; -> "[X]" "[[199.4, 2.6, 29.5], [212.2, 3.46, 11.7], [182.2, 3.73, 12.1], [205.5, 5.31, 13.7], [217.6, 5.79, 27.3], [238.6, 2.19, 35.8], [188.7, 2.47, 19.3], [190.8, 4.33, 29.2], [212.9, 2.25, 11.8], [220.8, 3.71, 19.4], [207.2, 3.2, 33.8], [194.6, 4.3, 25.8], [223.8, 3.15, 39.4], [205.1, 5.03, 14.6], [182.4, 4.67, 32.9], [232.5, 3.25, 30.9], [214.8, 3.82, 35.2], [208.4, 4.66, 11.8], [218.8, 5.97, 34.7], [203.1, 4.67, 10.7], [190.1, 2.47, 11.8], [187.8, 2.99, 21.7], [184.8, 3.8, 26.5], [229.2, 5.46, 18.4], [201.5, 5.54, 38.7], [190.6, 2.93, 17.0], [215.3, 3.05, 10.1], [202.2, 4.27, 38.6], [210.9, 4.47, 30.3], [234.0, 5.12, 36.2], [203.5, 3.6, 13.1], [183.7, 2.27, 16.3], [200.4, 2.21, 10.0], [186.1, 3.45, 10.8], [216.8, 2.59, 17.6], [201.8, 2.49, 35.5], [208.0, 3.94, 12.6], [200.6, 3.06, 34.9], [181.4, 5.8, 25.8], [212.6, 2.11, 25.8], [231.8, 4.78, 17.8], [190.0, 5.09, 26.0], [199.8, 2.89, 34.3], [231.2, 5.22, 34.5], [193.6, 4.07, 20.7], [181.7, 3.12, 17.8], [237.4, 3.79, 38.1], [237.3, 3.46, 16.6], [191.8, 2.82, 28.7], [230.4, 3.92, 29.6], [185.1, 4.64, 37.3], [225.0, 3.91, 15.4], [200.0, 5.2, 39.1], [204.1, 5.79, 31.7], [187.6, 2.6, 37.1], [188.8, 5.31, 39.4], [201.0, 4.19, 13.9], [238.3, 4.6, 25.8], [206.0, 5.49, 34.8], [195.1, 3.17, 17.2], [195.6, 3.68, 13.9], [201.2, 3.83, 27.5], [205.2, 5.67, 25.0], [211.4, 2.07, 23.2], [180.2, 5.2, 15.2], [223.5, 4.23, 19.8], [213.3, 5.14, 13.2], [194.9, 3.11, 33.2], [213.7, 5.04, 37.4], [216.8, 4.02, 25.4], [207.1, 4.13, 24.3], [222.0, 5.51, 38.3], [213.6, 5.77, 35.2], [187.3, 3.77, 12.2], [184.4, 4.68, 33.5], [189.3, 4.86, 29.8], [233.0, 5.87, 16.6], [203.9, 3.95, 39.7], [189.7, 3.73, 25.5], [191.7, 3.27, 31.7], [213.2, 3.76, 10.5], [217.4, 4.05, 11.9], [227.3, 5.89, 13.1], [182.4, 5.12, 18.1], [205.3, 5.65, 34.6], [189.0, 5.68, 27.1], [185.4, 2.23, 30.6], [184.3, 5.75, 29.0], [185.0, 5.42, 12.0], [207.2, 3.36, 26.6], [196.1, 2.52, 25.8], [186.6, 2.65, 11.5], [198.7, 3.22, 32.8], [210.0, 2.71, 20.4], [195.0, 2.06, 32.0], [191.4, 3.9, 38.0], [229.1, 3.73, 24.9], [203.6, 4.03, 30.6], [200.6, 5.33, 31.2], [204.3, 3.39, 11.6], [184.2, 4.96, 17.7], [185.1, 5.37, 36.1], [196.9, 2.97, 18.8], [189.5, 3.78, 17.9], [238.4, 4.19, 17.3], [198.6, 3.43, 10.0], [208.5, 4.01, 16.0], [180.3, 3.06, 12.7], [182.5, 2.09, 19.1], [215.1, 4.12, 32.5], [223.0, 5.52, 21.7], [239.1, 2.6, 31.7], [182.6, 5.34, 36.8], [224.0, 5.25, 14.2], [210.3, 5.34, 34.1], [215.0, 5.57, 30.5], [193.8, 2.12, 14.0], [186.3, 5.34, 26.8], [217.6, 4.72, 24.7], [227.9, 4.99, 25.1], [219.6, 2.26, 32.1], [184.5, 3.06, 31.9], [224.4, 5.9, 24.8], [208.7, 4.73, 33.0], [218.6, 2.31, 14.4], [224.6, 3.22, 27.0], [183.6, 3.08, 30.2], [220.5, 3.16, 25.5], [208.0, 2.47, 36.8], [238.7, 5.75, 10.5], [229.2, 5.87, 23.5], [192.6, 5.78, 16.3], [188.5, 4.1, 38.6], [229.2, 4.03, 36.6], [193.9, 5.59, 24.6], [180.2, 3.97, 23.5], [188.4, 3.38, 19.5], [180.1, 5.0, 35.2], [235.6, 4.85, 37.0], [202.3, 3.57, 40.0], [201.6, 3.71, 18.3], [186.1, 5.34, 18.6], [195.0, 3.06, 25.3], [202.4, 5.82, 36.5], [217.9, 5.65, 38.2], [223.2, 2.2, 32.0], [225.2, 4.58, 18.6], [235.6, 2.51, 24.2], [197.9, 4.96, 39.3], [219.4, 3.2, 26.7]]"; -> "[y]" "[\"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"defect\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"defect\", \"defect\", \"ok\", \"ok\", \"defect\", \"ok\", \"defect\", \"ok\", \"defect\", \"defect\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"defect\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"defect\", \"ok\", \"ok\", \"ok\", \"defect\", \"defect\", \"defect\", \"ok\", \"ok\", \"ok\", \"defect\", \"defect\", \"ok\", \"ok\", \"ok\", \"defect\", \"defect\", \"defect\", \"ok\", \"defect\", \"defect\", \"ok\"]"; json load "rx_m" (ml train "rx_rip" "ripper" [X] [y] "{}"); json load "rx_r" (ml model rules "rx_rip"); -> "[res]" (concat "RIPPER, training accuracy " (math round (json select "rx_m" "/training_accuracy") 3) ": "); for (-> "[i]" 0) (< [i] (json count "rx_r" /)) (++ "[i]") { -> "[res]" (concat [res] "if " (json select "rx_r" (concat "/[" [i] "]/if")) " then " (json select "rx_r" (concat "/[" [i] "]/then")) "; "); }; json load "rx_o" (ml train "rx_one" "one_r" [X] [y] "{}"); -> "[res]" (concat [res] "| OneR uses x" (json select "rx_o" "/feature") ", accuracy " (math round (json select "rx_o" "/training_accuracy") 3)); ml model delete "rx_rip"; ml model delete "rx_one"; json unload "rx_m"; json unload "rx_r"; json unload "rx_o"; [res]
RIPPER, training accuracy 0.94: if x2 > 35.65 then defect; if x0 > 228.5 and x1 <= 3.825 then defect; if true then ok; | OneR uses x2, accuracy 0.907
- x0 = temperature, x1 = pressure, x2 = speed: the rules can be pasted in a work instruction.
- Check the rules on new parts with
ml model evaluatebefore using them.
Inspection driven by the cost of errors
A defective part shipped to the customer costs 20, a good part sent to rework costs 1: a classifier that minimizes the expected cost catches more defects and lowers the total cost on the test set.
#1. Parts: weld temperature, porosity index, classes sorted as defect then ok; -> "[X]" "[[48.6, 1.0], [52.4, 0.76], [50.5, 0.49], [49.2, 0.72], [52.9, 0.83], [49.9, 0.65], [47.4, 0.8], [58.1, 0.65], [41.2, 1.22], [55.1, 0.94], [51.2, 0.72], [48.9, 0.55], [52.0, 0.76], [44.0, 0.7], [52.3, 0.92], [56.2, 1.03], [40.1, 0.91], [53.5, 1.08], [52.6, 0.39], [52.9, 0.82], [54.7, 0.91], [49.4, 1.45], [46.3, 1.04], [51.5, 0.69], [42.9, 0.62], [47.2, 0.77], [49.4, 1.15], [51.4, 1.05], [50.4, 0.96], [53.0, 1.01], [52.3, 0.71], [46.8, 1.18], [47.9, 0.72], [55.0, 0.82], [48.1, 0.98], [53.4, 1.33], [49.7, 0.63], [57.9, 1.07], [50.5, 0.78], [45.8, 0.68], [46.0, 0.99], [53.9, 0.73], [52.5, 1.13], [50.0, 0.91], [51.6, 0.89], [52.0, 0.59], [52.3, 0.38], [50.4, 0.74], [51.2, 0.76], [54.8, 0.67], [48.3, 0.63], [51.1, 0.84], [48.5, 0.69], [47.7, 0.77], [51.3, 0.94], [49.5, 0.57], [51.3, 1.19], [46.6, 0.72], [42.6, 0.98], [50.0, 0.66], [49.2, 0.92], [49.5, 0.84], [49.9, 0.54], [48.4, 1.25], [48.1, 1.03], [53.5, 0.69], [47.8, 0.68], [55.0, 0.8], [49.1, 0.98], [47.0, 0.67], [52.1, 1.03], [45.8, 0.66], [50.3, 0.58], [46.7, 0.88], [46.7, 0.75], [52.3, 0.81], [55.6, 0.77], [49.1, 1.12], [50.6, 0.95], [45.4, 0.77], [53.3, 0.84], [53.4, 0.65], [51.4, 0.8], [54.8, 0.59], [57.7, 1.09], [50.1, 0.66], [46.5, 0.49], [50.9, 0.6], [53.5, 0.89], [51.4, 1.03], [49.7, 0.98], [48.7, 0.95], [53.0, 0.77], [55.0, 0.82], [47.3, 1.09], [50.4, 0.75], [49.7, 0.64], [48.8, 0.96], [51.8, 1.01], [47.6, 0.81], [51.6, 0.91], [48.9, 0.64], [50.9, 0.98], [52.0, 1.36], [50.4, 0.69], [53.1, 1.26], [47.1, 0.77], [45.0, 0.75], [52.2, 1.01], [51.9, 1.01], [47.8, 1.13], [55.5, 0.46], [50.5, 1.2], [52.3, 1.08], [50.6, 0.59], [47.8, 1.1], [50.0, 0.44], [49.5, 0.94], [50.0, 0.93], [55.5, 1.05], [46.8, 0.81], [52.2, 0.68], [53.3, 1.21], [52.5, 0.88], [50.2, 0.62], [54.8, 0.73], [51.9, 1.42], [53.2, 0.69], [50.9, 0.87], [52.6, 0.42], [47.1, 0.52], [50.6, 0.66], [51.4, 1.19], [55.7, 0.87], [49.8, 0.88], [44.6, 1.05], [50.8, 0.97], [53.8, 0.86], [54.2, 0.91], [46.9, 0.81], [53.9, 1.22], [55.6, 0.5], [50.0, 0.66], [50.7, 0.98], [55.1, 0.46], [50.5, 1.08], [47.6, 0.95], [55.6, 1.35], [51.4, 0.34], [46.8, 0.82], [49.0, 0.72], [53.7, 0.56], [50.4, 1.0], [44.2, 0.83], [53.2, 0.91], [56.6, 0.66], [52.2, 0.62], [47.0, 0.83], [53.4, 0.77], [51.9, 0.77]]"; -> "[y]" "[\"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\"]"; -> "[Xt]" "[[53.3, 0.84], [54.7, 1.2], [51.5, 0.82], [48.8, 0.83], [48.8, 1.06], [49.8, 0.97], [48.3, 0.91], [45.2, 0.67], [57.6, 1.1], [43.4, 0.7], [49.3, 0.65], [45.2, 0.51], [54.9, 0.7], [52.3, 0.92], [47.3, 0.82], [54.2, 0.82], [50.4, 0.8], [50.5, 0.71], [48.3, 0.79], [47.0, 0.99], [50.8, 0.79], [48.9, 0.86], [53.9, 0.94], [51.8, 1.14], [56.0, 0.92], [48.9, 1.46], [51.1, 0.86], [47.5, 0.83], [48.4, 0.67], [53.7, 1.08], [50.2, 0.81], [44.1, 0.9], [47.4, 0.76], [45.1, 0.89], [50.9, 0.74], [48.5, 0.67], [58.3, 0.91], [46.2, 0.64], [50.1, 0.72], [49.6, 0.85], [53.9, 1.18], [48.2, 0.74], [49.1, 1.0], [58.7, 1.24], [49.3, 0.85], [46.9, 0.78], [50.2, 0.64], [50.3, 1.04], [48.7, 0.86], [49.5, 0.4], [56.1, 0.79], [44.8, 0.86], [50.3, 0.89], [51.0, 1.04], [50.8, 1.01], [51.6, 0.54], [50.5, 0.9], [55.0, 1.05], [49.7, 1.11], [51.4, 0.63], [53.7, 0.87], [50.5, 0.79], [42.7, 0.29], [48.2, 1.04], [55.7, 0.78], [52.5, 1.11], [46.2, 0.65], [45.4, 0.58], [43.9, 0.6], [50.5, 0.83], [52.3, 0.98], [52.7, 0.61], [50.4, 0.8], [46.8, 1.0], [48.0, 0.9], [51.4, 1.1], [44.2, 0.49], [48.4, 1.0], [58.5, 0.98], [49.7, 1.12]]"; -> "[yt]" "[\"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"ok\", \"defect\", \"ok\"]"; #2. cost[true][predicted]: a missed defect costs 20, a false alarm 1; -> "[cost]" "[[0, 20], [1, 0]]"; ml train "rx_nb" "naive_bayes" [X] [y] "{}"; ml train "rx_cs" "cost_sensitive_classifier" [X] [y] (concat "{\"base\": \"naive_bayes\", \"cost\": " [cost] "}"); json load "rx_a" (ml metrics cost [yt] (ml model predict "rx_nb" [Xt]) [cost]); json load "rx_b" (ml metrics cost [yt] (ml model predict "rx_cs" [Xt]) [cost]); -> "[res]" (concat "plain: cost " (json select "rx_a" "/total_cost") ", defects missed " (json select "rx_a" "/confusion/[0]/[1]") " | cost-sensitive: cost " (json select "rx_b" "/total_cost") ", defects missed " (json select "rx_b" "/confusion/[0]/[1]") ", false alarms " (json select "rx_b" "/confusion/[1]/[0]")); ml model delete "rx_nb"; ml model delete "rx_cs"; json unload "rx_a"; json unload "rx_b"; [res]
plain: cost 182, defects missed 9 | cost-sensitive: cost 56, defects missed 1, false alarms 36
- The classes of the cost matrix are sorted as in
ml model info: here defect then ok. - {"method": "reweight"} trains the base on rows resampled by their cost, for the models without probabilities.
Defect counts with overdispersion
Count the surface defects per coil against the line speed: the counts vary more than a Poisson law, so the negative binomial GLM gives honest standard errors and a better AIC.
#1. Line speed in m/s, number of defects per coil; -> "[X]" "[[2.12], [3.35], [1.44], [2.41], [4.42], [2.86], [1.92], [2.1], [1.68], [1.33], [2.95], [1.81], [1.24], [1.55], [2.04], [1.38], [1.87], [4.11], [3.48], [4.98], [4.27], [1.44], [2.2], [2.88], [3.54], [3.38], [3.08], [2.55], [1.8], [4.24], [1.0], [2.44], [3.36], [3.39], [3.13], [2.98], [4.45], [1.83], [4.42], [2.08], [1.7], [1.7], [3.82], [3.19], [4.7], [1.05], [2.85], [4.3], [3.28], [3.59]]"; -> "[y]" "[3, 3, 0, 2, 4, 16, 0, 0, 5, 1, 10, 1, 1, 2, 3, 0, 6, 5, 4, 2, 3, 1, 5, 1, 0, 5, 6, 0, 2, 5, 1, 1, 10, 13, 2, 5, 4, 1, 2, 3, 0, 0, 10, 7, 2, 2, 3, 3, 2, 8]"; json load "rx_p" (stat glm [X] [y] "poisson"); json load "rx_n" (stat glm [X] [y] "negative_binomial"); -> "[res]" (concat "Poisson: dispersion " (math round (/ (json select "rx_p" "/deviance") (json select "rx_p" "/df_residual")) 2) ", se " (math round (json select "rx_p" "/coefficients/[1]/se") 3) ", AIC " (math round (json select "rx_p" "/aic") 1) " | negative binomial: theta " (math round (json select "rx_n" "/theta") 2) ", se " (math round (json select "rx_n" "/coefficients/[1]/se") 3) ", AIC " (math round (json select "rx_n" "/aic") 1) " | +1 m/s = x" (math round (math exp (json select "rx_n" "/coefficients/[1]/estimate")) 2) " defects"); json unload "rx_p"; json unload "rx_n"; [res]
Poisson: dispersion 2.91, se 0.069, AIC 271.5 | negative binomial: theta 1.9, se 0.12, AIC 234.1 | +1 m/s = x1.5 defects
- deviance / df_residual far above 1 is the sign of overdispersion.
- exp(coefficient) is the rate ratio of the log link.
Failure rate of a new supplier
A new supplier delivered parts that ran 1000 hours with 12 failures: the Bayesian posterior of the failure rate gives a credible interval and the probability that the rate exceeds the target of 1 failure per 100 hours.
json load "rx_r" (stat bayes_rate 12 1000 "{\"threshold\": 0.01}"); json load "rx_p" (stat bayes_proportion 3 150 "{\"threshold\": 0.02}"); -> "[res]" (concat "failures per 100 h: " (math round (* 100 (json select "rx_r" "/mean")) 2) " [" (math round (* 100 (json select "rx_r" "/lower")) 2) ", " (math round (* 100 (json select "rx_r" "/upper")) 2) "], P(rate > target) = " (math round (json select "rx_r" "/probability_above") 3) " | incoming defects 3/150: P(> 2 %) = " (math round (json select "rx_p" "/probability_above") 3)); json unload "rx_r"; json unload "rx_p"; [res]
failures per 100 h: 1.25 [0.66, 2.03], P(rate > target) = 0.747 | incoming defects 3/150: P(> 2 %) = 0.643
- With an informative prior from the other suppliers: {"prior": [shape, rate]} for the rate, {"prior": [a, b]} for the proportion.
- The probability above the target is easier to explain to a buyer than a p-value.
Filling line: control chart, small shift and capability
A filling machine fills 250 g packs (specifications 247 to 254 g). The individuals chart checks that the process is stable, the EWMA chart detects the small drift of the last packs that the 3 sigma limits miss, and the capability on the stable period says whether the machine can respect the specifications.
#1. 50 weights in production order; -> "[w]" "[249.34, 249.37, 251.0, 248.34, 250.27, 248.37, 251.39, 250.58, 251.62, 249.95, 250.76, 250.14, 249.74, 250.53, 249.27, 250.08, 251.03, 250.45, 250.03, 252.37, 250.45, 249.87, 250.54, 249.93, 250.05, 250.08, 252.22, 250.42, 250.56, 251.01, 252.22, 250.2, 249.84, 252.63, 249.09, 250.07, 251.0, 252.46, 249.55, 248.22, 252.2, 251.13, 251.25, 252.02, 251.8, 251.86, 251.21, 252.76, 252.95, 251.63]"; json load "rx_i" (stat control_chart "imr" [w]); json load "rx_e" (stat control_chart "ewma" [w] "{\"target\": 250.4}"); json load "rx_c" (stat capability (json select "rx_i" "/charts/[0]/values") "{\"lsl\": 247, \"usl\": 254}"); -> "[res]" (concat "individuals: points beyond 3 sigma " (json select "rx_i" "/charts/[0]/out_of_control") ", first Western Electric signal at " (json select "rx_i" "/charts/[0]/western_electric/[0]/index") " | first EWMA alarm at " (json select "rx_e" "/charts/[0]/out_of_control/[0]") " | Cp " (math round (json select "rx_c" "/cp") 2) ", Cpk " (math round (json select "rx_c" "/cpk") 2) " [" (math round (json select "rx_c" "/cpk_lower") 2) ", " (math round (json select "rx_c" "/cpk_upper") 2) "], " (json select "rx_c" "/verdict")); json unload "rx_i"; json unload "rx_e"; json unload "rx_c"; [res]
individuals: points beyond 3 sigma [], first Western Electric signal at 5 | first EWMA alarm at 47 | Cp 1.08, Cpk 1.03 [0.8, 1.25], barely capable (1 <= Cpk < 1.33)
- Compute the capability on a stable period only: here the shift of the last packs lowers the Cpk.
- stat run_chart tests the randomness of the series (clustering, mixtures, trends).
Is the caliper good enough? Gage R&R study
10 parts are measured 3 times by 3 operators with the same caliper. The Gage R&R separates the variation of the parts from the variation of the measurement (repeatability of the instrument, reproducibility between operators) and gives the number of distinct categories the gauge can see.
#1. 90 measures (mm), part and operator of each; -> "[m]" "[11.42, 11.477, 11.448, 11.45, 11.477, 11.312, 11.414, 11.332, 11.364, 12.107, 12.247, 12.221, 12.176, 12.102, 12.06, 12.095, 12.13, 12.113, 12.864, 12.802, 12.93, 12.828, 12.907, 12.803, 12.746, 12.71, 12.808, 13.03, 12.977, 12.992, 12.917, 12.908, 12.916, 12.793, 12.844, 12.907, 12.763, 12.821, 12.793, 12.746, 12.724, 12.586, 12.696, 12.64, 12.722, 12.059, 12.056, 12.043, 12.023, 11.924, 11.945, 12.085, 12.038, 11.986, 12.224, 12.223, 12.439, 12.241, 12.21, 12.169, 12.04, 12.189, 12.264, 11.955, 11.916, 11.864, 11.794, 11.869, 11.84, 11.769, 11.935, 11.781, 11.231, 11.121, 11.365, 11.219, 11.224, 11.246, 11.15, 11.163, 11.218, 11.719, 11.788, 11.841, 11.779, 11.818, 11.798, 11.81, 11.723, 11.731]"; -> "[p]" "[\"P01\", \"P01\", \"P01\", \"P01\", \"P01\", \"P01\", \"P01\", \"P01\", \"P01\", \"P02\", \"P02\", \"P02\", \"P02\", \"P02\", \"P02\", \"P02\", \"P02\", \"P02\", \"P03\", \"P03\", \"P03\", \"P03\", \"P03\", \"P03\", \"P03\", \"P03\", \"P03\", \"P04\", \"P04\", \"P04\", \"P04\", \"P04\", \"P04\", \"P04\", \"P04\", \"P04\", \"P05\", \"P05\", \"P05\", \"P05\", \"P05\", \"P05\", \"P05\", \"P05\", \"P05\", \"P06\", \"P06\", \"P06\", \"P06\", \"P06\", \"P06\", \"P06\", \"P06\", \"P06\", \"P07\", \"P07\", \"P07\", \"P07\", \"P07\", \"P07\", \"P07\", \"P07\", \"P07\", \"P08\", \"P08\", \"P08\", \"P08\", \"P08\", \"P08\", \"P08\", \"P08\", \"P08\", \"P09\", \"P09\", \"P09\", \"P09\", \"P09\", \"P09\", \"P09\", \"P09\", \"P09\", \"P10\", \"P10\", \"P10\", \"P10\", \"P10\", \"P10\", \"P10\", \"P10\", \"P10\"]"; -> "[o]" "[\"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\", \"Op1\", \"Op1\", \"Op1\", \"Op2\", \"Op2\", \"Op2\", \"Op3\", \"Op3\", \"Op3\"]"; json load "rx_g" (stat gage_rr [m] [p] [o] "{\"tolerance\": 4}"); -> "[res]" (concat "%GRR (study variation) " (math round (json select "rx_g" "/gage_rr_percent") 1) " %: " (json select "rx_g" "/verdict") " | repeatability sd " (math round (json select "rx_g" "/components/[1]/sd") 4) ", reproducibility sd " (math round (json select "rx_g" "/components/[2]/sd") 4) " | % tolerance " (math round (json select "rx_g" "/components/[0]/tolerance_percent") 1) " | ndc " (json select "rx_g" "/ndc")); json unload "rx_g"; [res]
%GRR (study variation) 12.5 %: conditionally acceptable (10 - 30 %) | repeatability sd 0.0596, reproducibility sd 0.0418 | % tolerance 10.9 | ndc 11
- ndc >= 5 is required to use the gauge for process control.
- stat gage_bias checks the bias and the linearity of the gauge against reference parts.
Production line: system reliability, critical component and preventive replacement
A line has a feed pump, two filters in parallel and 2 sensors out of 3 that must work. The block diagram gives the reliability of the line over a shift and the Birnbaum importance shows the component to improve first; the pump bearings (Weibull shape 2.5, scale 1000 h) are replaced preventively at the interval of minimum cost, and the stock of spare bearings covers a year for 10 pumps.
json load "rx_s" (maint system "{\"series\": [{\"name\": \"pump\", \"r\": 0.97}, {\"parallel\": [{\"name\": \"filter1\", \"r\": 0.9}, {\"name\": \"filter2\", \"r\": 0.9}]}, {\"k_of_n\": 2, \"items\": [{\"name\": \"sensor1\", \"r\": 0.95}, {\"name\": \"sensor2\", \"r\": 0.95}, {\"name\": \"sensor3\", \"r\": 0.95}]}]}"); json load "rx_r" (maint age_replacement 2.5 1000 300 2500); json load "rx_k" (maint spares (/ 1 (json select "rx_r" "/mttf")) 8760 0.95 "{\"units\": 10}"); json load "rx_v" (maint availability 2000 6 "{\"pm_interval\": 720, \"pm_duration\": 2}"); -> "[res]" (concat "line reliability " (math round (json select "rx_s" "/system_reliability") 4) " | most important: " (json select "rx_s" "/components/[0]/component") " (Birnbaum " (math round (json select "rx_s" "/components/[0]/birnbaum_importance") 3) ") | replace the bearings every " (math round (json select "rx_r" "/optimal_interval") 0) " h: cost rate " (math round (json select "rx_r" "/cost_rate") 3) " per h against " (math round (json select "rx_r" "/cost_rate_run_to_failure") 3) " in run to failure (" (math round (* 100 (json select "rx_r" "/saving")) 0) " % saved) | spares for 10 pumps (failures only): " (json select "rx_k" "/spares") " | achieved availability " (math round (* 100 (json select "rx_v" "/achieved_availability")) 2) " %"); json unload "rx_s"; json unload "rx_r"; json unload "rx_k"; json unload "rx_v"; [res]
line reliability 0.9533 | most important: pump (Birnbaum 0.983) | replace the bearings every 385 h: cost rate 1.315 per h against 2.818 in run to failure (53 % saved) | spares for 10 pumps (failures only): 115 | achieved availability 99.43 %
- The Weibull shape and scale come from stat weibull on the failure and suspension times of the bearings.
- The spares are computed here on the failure rate of the MTTF; with the preventive policy, add the planned replacements (8760 / interval per pump).
