tighter sigma\n return rng.normal(mu, sigma, 500)\nprint('spec band:', LSL, '-', USL)","label":"1 — Batch generator + spec"},{"code":"bore_offset = -0.070 # EDIT: shift mu toward 12.000 (centering, free)\nfeed_per_rev = 0.10 # EDIT: lower -> tighter sigma (narrowing, costs cycle time)\nctq = batch_ctq(seed=5101, bore_offset=bore_offset, feed_per_rev=feed_per_rev)\nmu, sigma = ctq.mean(), ctq.std(ddof=1)\nyield_frac = float(np.mean((ctq >= LSL) & (ctq <= USL)))\nscrap = int(np.sum((ctq < LSL) | (ctq > USL)))\nCp = (USL - LSL) / (6*sigma)\nCpk = min((USL - mu)/(3*sigma), (mu - LSL)/(3*sigma))\ncycle_s = 4.0 + (0.10 - feed_per_rev)*13.0 # narrowing raises cycle time\nprint(f'mu={mu:.4f} sigma={sigma:.4f} yield={yield_frac:.2%} scrap={scrap}/500')\nprint(f'Cp={Cp:.2f} Cpk={Cpk:.2f} cycle={cycle_s:.1f}s')","label":"2 — Your settings (EDIT) + capability"},{"code":"twist = batch_ctq(seed=5102, bore_offset=(12.000-12.07), feed_per_rev=feed_per_rev)\ntmu, tsig = twist.mean(), twist.std(ddof=1)\ntyield = float(np.mean((twist>=LSL)&(twist<=USL)))\nprint(f'twist: mu={tmu:.4f} sigma={tsig:.4f} yield={tyield:.2%} (centering wont help; narrow sigma)')","label":"3 — Twist seed 5102 (already centered, wide)"},{"code":"problems = []\nif yield_frac < 0.98:\n if abs(mu-12.000) > 0.01:\n problems.append(f'mu={mu:.3f} off-center - apply bore_offset ~ {12.000-12.07:+.3f} before touching feed; yield is capped by off-centering, not spread.')\n else:\n problems.append('centered but yield short - narrow sigma (lower feed_per_rev).')\n# G3: base task should be solved by centering, not paid narrowing\nif yield_frac >= 0.98 and feed_per_rev < 0.10:\n problems.append(f'yield reached but you lowered feed (cycle {cycle_s:.1f}s) - the base process was only off-center; re-center at zero cycle cost.')\n# G4 twist: needs narrowing\ntwist_ok = tyield >= 0.98 and tsig <= 0.019\n\nif yield_frac >= 0.98 and feed_per_rev >= 0.099 and abs(Cpk-Cpk) < 0.03:\n print(f'PASS - base yield {yield_frac:.1%} >= 98% by centering alone (Cpk={Cpk:.2f}), '\n f'at zero cycle cost. Center before you narrow.')\nelse:\n print('FAIL - ' + ' '.join(problems[:2] if problems else ['raise yield to >=98% with the cheapest correct lever.']))","label":"4 — Autograder (seeds 5101 + 5102)"}],"intro":"The Yield & Capability panel streams the batch's measured bore into numpy; you compute yield, Cp, Cpk yourself, then center or narrow Station C. Edit the offset/feed and run.","key":"manufacturing/yield-scrap-and-process-capability","kind":"python","title":"Yield, scrap & process capability"}">
PYTHON · NUMPY · IN-BROWSER

Yield, scrap & process capability

The Yield & Capability panel streams the batch's measured bore into numpy; you compute yield, Cp, Cpk yourself, then center or narrow Station C. Edit the offset/feed and run.