L2 · PAI-150

Tolerance stack-up

Predict whether a chain of toleranced parts will assemble using both worst-case and statistical (RSS) stacks, and state when each method applies.

01
Challenge

Try this first — before any explanation.

A 3-part stack (plate 6.000, spacer 9.000, cap 5.000) drops into a housing pocket of depth 20.200; the retaining-clip gap must stay in 0.10–0.50 mm. With supplier tolerances (plate ±0.10, spacer ±0.12, cap ±0.08, housing ±0.05), will the clip always fit? Compute the worst-case range, then run Monte-Carlo 5000 and notice how much head-room the statistical answer gives. Tighten the cheapest tolerances until guaranteed.

The Bench

Both stack methods plus a deterministic 5000-draw Monte-Carlo, exactly as the autograder uses. Edit the tolerances to guarantee the fit.

GAP_MAX)))\n return gap.mean(), gap.std(), fail\nmc_mean, mc_sd, mc_fail = monte_carlo()\nprint(f'MC: mean={mc_mean:.3f} sigma={mc_sd:.3f} out-of-spec={mc_fail:.4%}')","label":"3 — Monte-Carlo 5000 (seed 303)"},{"code":"# Your typed predictions (EDIT to match what you computed):\ntyped_wc_sum = HOUSING[1] + sum(p[1] for p in PARTS.values())\ntyped_rss = float(np.sqrt(HOUSING[1]**2 + sum(p[1]**2 for p in PARTS.values())))\nref_wc = HOUSING[1] + sum(p[1] for p in PARTS.values())\nref_rss = float(np.sqrt(HOUSING[1]**2 + sum(p[1]**2 for p in PARTS.values())))\n\nproblems = []\nguaranteed = (wc[0] >= GAP_MIN) and (wc[1] <= GAP_MAX)\nif not guaranteed:\n problems.append(f'worst-case gap [{wc[0]:.3f},{wc[1]:.3f}] leaves the {GAP_MIN}-{GAP_MAX} window - tighten the largest contributor (spacer) until worst-case low >= 0.10.')\nif abs(typed_wc_sum-ref_wc) > 0.005:\n problems.append('typed worst-case sum is off - it is the LINEAR sum of tolerances.')\nif abs(typed_rss-ref_rss) > 0.005:\n problems.append('typed RSS is off - square each tol, add, then square-root.')\ncheapest = (1/0.06) # tightening spacer alone reference cost share\n\nif guaranteed and abs(typed_wc_sum-ref_wc)<=0.005 and abs(typed_rss-ref_rss)<=0.005:\n print(f'PASS - worst-case gap guaranteed in [{GAP_MIN},{GAP_MAX}], wc_sum={ref_wc:.3f}, '\n f'rss={ref_rss:.3f}. RSS < worst-case because independent errors rarely all hit extreme together.')\nelse:\n print('FAIL - ' + ' '.join(problems[:2]))","label":"4 — Autograder (seed 303)"}],"intro":"Both stack methods plus a deterministic 5000-draw Monte-Carlo, exactly as the autograder uses. Edit the tolerances to guarantee the fit.","key":"manufacturing/tolerance-stack-up","kind":"python","title":"Tolerance stack-up"}">
PYTHON · NUMPY · IN-BROWSER

Tolerance stack-up

Both stack methods plus a deterministic 5000-draw Monte-Carlo, exactly as the autograder uses. Edit the tolerances to guarantee the fit.

02
Model

The idea, built visually.

Three parts — six, nine, five — sum to twenty, leaving a two-tenths gap; the clip fits at nominal. But nothing is at nominal, and each part's little band stacks. The pessimist's method, worst-case: assume every part lands at its worst extreme at once and just add the tolerances — 0.10+0.12+0.08+0.05 = 0.35 mm of swing, which can eat the whole gap. Worst-case is a guarantee: fit here and it fits always.

But all four hitting their worst extreme simultaneously is wildly unlikely — they're independent draws. So the statistical stack combines them as root-sum-of-squares: √(0.10²+0.12²+0.08²+0.05²) = 0.18 — half the worst-case. Both are true. Worst-case never fails but forces tight, costly tolerances; RSS is realistic and cheaper but admits a tiny reject rate.

▣ Stage animation: Worst-case: every band snaps to its extreme, the gap crushes toward zero, tolerances sum linearly to 0.35; then a Monte-Carlo cloud of 5000 rains in forming a narrow RSS bell at 0.18, half as wide, with a few tails poking past.

03
Guided practice

Build it up, step by step.

  1. Step A (worked): nominal gap 0.200; worst-case Σ|tol| = 0.350 → [−0.150, 0.550] FAIL; RSS √Σtol² = 0.1825 → [0.018, 0.382], still fails low but far less.
  2. Step B (fade): compute worst-case sum and RSS for a new supplier set; the Monte-Carlo overlay confirms RSS predicts the cloud width.
  3. Step C (independent): make the stack worst-case-safe at lowest cost — tightening the largest contributor (the spacer, 0.12) gives the most relief per cost unit — and state one scenario to ship the RSS answer.
04
Feedback

How the Bench grades your run.

PASS WHEN Worst-case gap range ⊆ [0.10,0.50] (guaranteed fit), typed worst-case sum and RSS each within ±0.005 mm of reference, the tightening costs ≤1.6× the cheapest worst-case-safe solution, and a correct RSS-vs-worst-case statement, on MC seed 303.

  • Worst-case gap is [−0.05, 0.45] — the low end is negative, so in the worst extreme the parts interfere. Tighten until the worst-case low ≥ 0.10 mm.
  • You entered 0.35 for RSS, but that's the linear (worst-case) sum. RSS = √(0.10²+0.12²+0.08²+0.05²) = 0.182. Re-enter the RSS value.
  • You tightened the cap (0.08), but the spacer (0.12) is the largest contributor — tightening it removes the most worst-case swing per cost unit.
  • The assembly is guaranteed, but you tightened every part to ±0.03 — cost 4.1×. You only needed the spacer and plate; loosen the cap back toward ±0.08.
05
Retrieve & space

Bring back what you've already mastered.

  • From 3.2: if a tool-wear drift shifts one part's mean off-nominal, is the RSS prediction still trustworthy? → no; RSS assumes centered/random, a systematic drift biases the stack.
  • From 3.1: roughly how much does halving the spacer's band cost? → ~doubles that part's cost share.
  • From M2: which sequencing/setup choice helps hold a tight thickness tolerance? → single-setup machining of the stack faces.
06
Mastery gate

What you must demonstrate to advance.

On a fresh 3-part stack seed with new nominals and gap, compute both worst-case and RSS ranges (±0.005), tighten so the stack is worst-case-guaranteed at ≤1.6× the cheapest such solution, and state when each method applies. Unlocks Module 4.

07
Project

How this feeds your build.

Feeds the M5 capstone: the worst-case-vs-RSS decision becomes a line-level yield lever; the same √Σtol² logic scales from a 3-part stack to the full assembly tolerance budget the capstone factory must satisfy.