IE 3301 Worked Examples
Teaching · IE 3301 Engineering Probability · Worked examples
Each section has one idea, a short explanation and something to try. The worked example is folded underneath, and it shows its work the same way every time:
- Write out the equation.
- List the variables: the terms in that equation.
- Fill in the equation with the numbers.
- Simplify, and box the answer.
- Distributions: mean, variance and area
- The central limit theorem
- Covariance and correlation
- Hypothesis tests, errors and power
- Linear regression
- A designed experiment
1. Distributions: mean, variance and area
- Calculate the mean, variance and standard deviation of a distribution
- Find a probability as a sum (discrete) or an area (continuous)
- Recognize the common distributions and what they model
A discrete variable counts and has a pmf (bars that sum to 1); a continuous one measures and has a pdf (a curve with area 1), where probability is area. The mean is the balance point, or , and the variance is .
Try it. Pick a distribution and move its parameters. Shade a probability, or draw random samples and watch their average settle on the mean.
Worked example: defective parts in a box (discrete)
= 0, 1, 2 or 3 defective parts, with probabilities 0.50, 0.30, 0.15 and 0.05.
- Equations: , .
- Variables: ; (they sum to 1).
- Fill in: ; .
- Answer:
Worked examples: probability as area (continuous)
A. on 0 to 1. Equation ; fill in ; answer 0.125. Its mean is .
B. Pump life is exponential with mean 200 h. Equation ; fill in ; answer
The common distributions at a glance
| Distribution | Models | pmf or pdf | Mean | Variance |
|---|---|---|---|---|
| Binomial() | successes in trials | |||
| Geometric() | trials until the first success | |||
| Poisson() | events in an interval | |||
| Uniform() | equally likely in a range | |||
| Exponential() | time between random events | |||
| Normal() | sums and averages |
2. The central limit theorem
- State the central limit theorem
- Find the standard error of a sample mean, σ/√n
- Explain when to use t instead of z
Average enough independent observations and the average is approximately normal, whatever the population looks like, with mean and standard error . That is why the normal is everywhere, and why works. When is estimated from the sample, use t instead: it has heavier tails, and approaches the normal as grows (try it in the explorer above).
Try it. Pick a population that is nothing like a bell curve, then raise the sample size. The averages turn normal anyway.
Worked example: bolts longer than 50.8 mm
Lengths are normal, mean 50 mm, SD 0.4 mm.
- Equation: .
- Variables: .
- Fill in: ; look up .
- Answer: about 2.3% of bolts
3. Covariance and correlation
- Find marginal distributions from a joint table
- Calculate covariance and correlation
- Check whether two variables are independent
A joint table gives the probability of each pair of values. Add up a row or column for one variable on its own (the marginal). is positive when the two tend to be high together; correlation scales it to between −1 and 1. Independent means every cell equals its row total times its column total.
Try it. Move probability around the table and watch the covariance and correlation respond. Can you make them independent?
| Y = 0 | Y = 1 | Y = 2 | total | |
|---|---|---|---|---|
| X = 0 no overtime | ||||
| X = 1 overtime | ||||
| total | 1 |
Worked example: overtime and defects
The explorer starts on this table: for an overtime shift, = defects found.
- Equations: , .
- Variables: ; ; .
- Fill in: ; .
- Answer: . Not independent: .
Correlation is not causation: overtime might cause defects, or a rush order might cause both. A designed experiment (section 6) is how to tell.
4. Hypothesis tests, errors and power
- State the hypotheses and find the critical value
- Decide with the test statistic or the confidence interval
- Explain Type I and Type II errors, the p-value and power
The critical values are the bounds of the confidence interval; the rejection region is everything outside. Reject if the test statistic falls outside them, or, the same thing, if the confidence interval misses . For a two-sided test, put in each tail.
| H₀ is true | H₀ is false | |
|---|---|---|
| Reject H₀ | Type I error (probability α) | correct: power, 1 − β |
| Fail to reject H₀ | correct | Type II error (probability β) |
Try it. Move the true mean away from 50 and watch the power grow. Then see what a bigger sample or a looser α does.
Worked example: is the bolt machine off target?
Ten bolts (mm): 50.3, 49.8, 50.6, 50.9, 50.2, 50.7, 49.9, 50.5, 50.8, 50.4. Target 50 mm, α = 0.05.
- Hypotheses: , .
- Equation: (σ unknown, so t).
- Variables: ; critical value .
- Fill in: .
- Answer: : reject H₀ (p ≈ 0.006). Same by the interval: misses 50.
5. Linear regression
- Fit a least-squares line
- Interpret the slope and R²
- Check the residuals
- Read the confidence band for the mean and the prediction band for one new point
Least squares picks the line that makes the squared vertical distances to the points (the residuals) as small as possible: , . is the share of the variation the line explains.
Try it. Click the chart to add points. Then try to beat least squares with your own slope.
Worked example: reactor temperature and yield
- Equations: , , .
- Variables: .
- Fill in: ; .
- Answer: . The slope test gives : temperature matters.
- Error bands at 185 °C (): the mean yield is = 69.06 to 70.17; one new run is = 67.94 to 71.28. The extra 1 under the root is the new run's own scatter.
6. A designed experiment
- Lay out a 2×2 factorial design
- Calculate main effects and the interaction
- Read the same results as a regression, and say why each coefficient is half its effect
- Use replicates to estimate the noise and test each effect
- Add a third level to see whether a factor's effect bends
Regression on data you happened to collect shows association; a designed experiment sets the factors, so it can show cause. Run every combination of two factors at two levels (coded −1 and +1), and lay the runs out as a table of signs before collecting anything: that table is the data-collection plan, and every run feeds every estimate. An effect is the average at + minus the average at −, and the interaction is the same for the product column. One run per cell gives the effects but no way to test them; replicates (repeat runs of each cell) measure the noise. A third level of a factor shows whether its effect is a straight line or bends.
Try it. Set each cell's average, then add replicates. With one run per cell, can any effect be tested? With two?
Worked example: temperature and time
- Equation: effect = (average where the column is +) − (average where it is −).
- Variables: yields 60, 72, 64, 84 at (A, B) = (−, −), (+, −), (−, +), (+, +).
- Fill in: A: ; B: ; AB: .
- Answer: A = 16, B = 8, AB = 4; as a regression, .
- Why 8 and not 16: the effect is the rise from to , a run of 2, so the slope is . It is section 5's too: coded has mean 0, so , , and .
With one run per cell, the four runs are used up by four estimates (the mean, A, B and AB), leaving no degrees of freedom for error. Is AB = 4 real or noise? This design cannot say.
Worked example: the same experiment, replicated
- Data: two runs per cell, (58, 62), (70, 74), (63, 65), (83, 85); N = 8. The cell averages are still 60, 72, 64, 84, so the effects are still A = 16, B = 8, AB = 4.
- Equations: pooled = the average of the four cells' variances, with df; each effect is an average of N/2 runs minus another, so , and .
- Fill in: cell variances 8, 8, 2, 2, so , , 4 df; ; t = 10.12, 5.06 and 2.53, against .
- Answer: A (p < 0.001) and B (p = 0.007) are real; AB (p = 0.065) is not distinguishable from noise. A two-way ANOVA gives the same tests: each F is t², 102.4, 25.6 and 6.4.
Worked example: a third level of time (2×3)
Temperature (A) at two levels and time (B) at three, two runs per cell (N = 12, 6 error df):
| B low | B mid | B high | row mean | |
|---|---|---|---|---|
| A low | 59, 61 → 60 | 65, 69 → 67 | 63, 65 → 64 | 63.67 |
| A high | 70, 74 → 72 | 80, 82 → 81 | 83, 85 → 84 | 79.00 |
| column mean | 66 | 74 | 74 | 71.33 |
- Curvature: the middle level against the straight line between the ends, . Two levels of time could not have shown it.
- Split B's 2 df with the contrasts (−1, 0, 1) and (1, −2, 1): , giving 128 (linear) and 42.67 (curvature), which add to B's 170.67.
| Source | SS | df | MS | F | p |
|---|---|---|---|---|---|
| A (temperature) | 705.33 | 1 | 705.33 | 176.33 | < 0.001 |
| B (time) | 170.67 | 2 | 85.33 | 21.33 | 0.002 |
| linear | 128.00 | 1 | 128.00 | 32.00 | 0.001 |
| curvature | 42.67 | 1 | 42.67 | 10.67 | 0.017 |
| AB | 34.67 | 2 | 17.33 | 4.33 | 0.068 |
| Error | 24.00 | 6 | 4.00 |
Answer: temperature and time both matter, time's effect bends (p = 0.017), and the interaction is not significant at 5% (p = 0.068). Checked against statsmodels' anova_lm.