Worked examples — Feature scaling - normalization vs standardization
This page is the worked-example lab for the parent topic. We do not re-derive the formulas here — we stress-test them. We throw every kind of input at the two scaling machines and watch what comes out.
The two machines, restated so you never scroll back:
Throughout, and . The symbol is a loop instruction: "let the counter run from 1 up to (the number of data points), and add up whatever follows for each value ." So = add all values, divide by how many; = average squared distance from the mean, then square-root back to original units. We use the population version (divide by ), matching the parent note.
The scenario matrix
Every situation these two formulas can face falls into one of these cells. The examples below each carry a tag like (C3) so you can see the whole grid gets covered. The figure below is a quick visual legend of the grid.

| Cell | Scenario class | What could go wrong |
|---|---|---|
| C1 | All positive, well-spread, no outlier | Baseline — both machines behave |
| C2 | Contains negative and zero values | Sign confusion; does shift correctly? |
| C3 | One large outlier present | Normalization compresses everyone else |
| C4 | Degenerate: all values identical | Range and → divide by zero |
| C5 | Two-value / tiny dataset | Formula still legal, min=one point, max=other |
| C6 | New (unseen) value beyond fitted min/max | Normalization escapes [0,1] (both above and below); z-score just grows |
| C7 | Two features, different units (real-world) | Distance domination before scaling |
| C8 | Exam twist: reverse-engineer original from scaled | Invert the transform algebraically |
We hit all eight below.
Worked examples
Forecast: Guess before reading — what should 40 become under each method? (It's the exact center, so...)
- Find min, max, range. , , range . Why this step? Normalization needs the two endpoints to know where "0" and "1" sit.
- Normalize each value: gives . Why this step? Subtracting the min shifts the smallest value to 0; dividing by the range squeezes the largest to 1, preserving each value's fraction of the way across the interval.
- Standardize. Mean . Deviations squared: ; average ; . Why this step? sets the "ruler" — one unit of z equals one of real spread.
- Z-scores: gives . Why this step? Subtracting recenters the data so the mean sits at 0; dividing by rescales so one ruler-unit of spread becomes one z-unit.
Verify: 40 is the mean, so its z-score must be exactly 0 — check. It's also the midpoint of the range, so its normalized value is exactly 0.5 — check. Both machines agree the middle value is "typical," but they label it differently (0.5 vs 0).
Forecast: Will °C get a z-score bigger or smaller than °C in size?
- Mean: . Why this step? The balance point can be positive even with negatives present — subtraction handles the signs.
- Deviations from 6: . Squared: . Sum , average , . Why this step? Squaring erases sign, so negatives and positives both count as "distance."
- Z-scores: ; ; ; ; . Why this step? Recentering (subtract ) makes each value's sign tell us "below vs above typical"; dividing by converts the raw gap into "how many standard deviations away."
Verify: Add the z-scores: — the mean of standardized data is always 0. And (distance 16 from mean) gets a larger-magnitude z than (distance 14) — matches intuition. Negatives caused zero trouble.

Forecast: Under normalization, how far apart will 1, 2, 3, 4 be on the [0,1] line?
- Normalize. , , range . Values: , , , , . Why this step? The single value 100 stretches the range to 99, so subtracting the min and dividing by that huge range crams everything else near 0.
- Standardize. . Deviations: ; squared ; sum ; average ; . Why this step? is dragged up by the outlier, but not only by it — the small values keep their own spacing.
- Z-scores: , , , , . Why this step? Recentering on then dividing by keeps the tiny 1-unit gaps between 1,2,3,4 as tiny-but-visible z-gaps instead of erasing them.
Verify: Normalized gap between 1 and 4 is — practically invisible. Standardized gap is — over 2.5× wider, and still readable. In the figure, look at the red points on the top line huddled at the left edge vs the blue points below staying legible. This is the parent note's "normalization fails with outliers" made concrete.
Forecast: What is ? What is ? What does that do to a fraction?
- Normalization denominator: . Why this step? The range measures spread; identical values have zero spread.
- Attempt the formula: — undefined. Division by zero. The machine crashes. Why this step? You cannot ask "what fraction of the way across a zero-width interval" — there's no interval.
- Standardization : all deviations are 0, so , and — also undefined. Why this step? With no spread, , and the z-score's denominator vanishes the same way the range did.
Verify: Both fail identically. This is why real libraries either drop constant columns or output all-zeros by convention (treating as 0). Rule to remember: a feature with no variation carries no information — scale-then-drop, or drop first. Relates to spotting constant features early (see 2.1.01-Feature-types-and-data-structures).
Forecast: With just two points, where must they land in each system?
- Normalize. , , range . , . Why this step? With exactly two distinct values, one is the min and the other is the max — subtracting the min then dividing by the range pins them to the endpoints 0 and 1.
- Standardize. . Deviations ; squared ; average ; . Why this step? We need the balance point and ruler before computing z-scores; two symmetric points sit exactly one deviation from their midpoint.
- Z-scores: , . Why this step? Recentering on makes the two points apart; dividing by turns those into exactly .
Verify: Any two-point dataset always normalizes to exactly and standardizes to exactly , regardless of the actual numbers. Sanity: z-scores sum to . ✓
Forecast: Normalization promised [0,1]. Can 1000 stay inside? Can 50?
- Apply the frozen training parameters (never re-fit on test data!). Range . Why this step? Fitting on test data leaks information; we reuse the training min/max so test values are judged by the training scale.
- Normalize 1000 (above max): . Why this step? The value sits beyond the training max, so the numerator exceeds the denominator → output escapes above 1.
- Normalize 50 (below min): . Why this step? The value sits below the training min, so the numerator goes negative → output escapes below 0. Normalization breaks its bound on both sides.
- Standardize instead. Train ; deviations ; squared ; avg ; . New values: and . Why this step? Z-scores are unbounded, so out-of-range values above or below just become large-but-valid numbers instead of breaking a promise.
Verify: and confirm normalization's bound is not guaranteed on future data — on either side. Standardization's and are unremarkable and interpretable ("about 2 std devs above / below train mean"). This is exactly the parent's "New data handling" comparison-table row.

Forecast: Before scaling, will the 2-bedroom difference matter at all next to the $10000 price gap?
- Raw distance. . Why this step? Euclidean distance (see 4.1.02-Distance-metrics-euclidean-manhattan-cosine) squares each feature's gap; the price gap of utterly swamps the bedroom gap of .
- Standardize using the training pair as the fitted per feature. Price: , → z's . Bedrooms: , → z's . Why this step? Each feature now speaks the same unit (standard deviations of its own training spread), removing the dollar-vs-room mismatch.
- Scaled distance. . Why this step? Both features now contribute equally — the bedroom difference is finally "heard."
Verify: Raw distance is driven by price alone (). After scaling, each feature contributes half the squared distance ( out of ). In the figure, notice the pre-scaling ellipse is stretched flat along the price axis; after scaling it's a circle. This is precisely why distance-based algorithms require scaling (links to 3.2.03-Gradient-descent-optimization convergence too).
Forecast: Standardization is a formula; can you run it backward algebraically?
- Invert standardization. Start from . Multiply both sides by : . Add : . Why this step? Every operation the machine did (subtract , divide by ) is undone in reverse order.
- Plug in: . Why this step? Substituting the known z, , into the inverted formula rebuilds the original value.
- Invert normalization. From , solve: . Why this step? Same undo logic: multiply back by the range, add the min.
- Plug in: . Why this step? Substituting the known normalized value and range rebuilds the pre-scaling number.
Verify: Re-standardize 72: ✓. Re-normalize 30: ✓. Both transforms are perfectly invertible because they are linear — a fact used when you must display predictions back in original units.
Recall
Recall Can Min-Max normalization ever produce a value outside [0,1], and how?
Yes ::: on unseen data — a test point above the fitted max gives , and a test point below the fitted min gives (Example 6). Standardization has no bound at all.
Recall What happens to both formulas on a constant column?
Both divide by zero ::: range for normalization and for standardization → undefined (Example 4).
Recall After standardization, what must the sum of all z-scores equal?
Zero ::: because the new mean is 0 (verified in Examples 2 and 5).
Connections: outlier behavior deepens in 2.1.05-Handling-outliers-detection-and-treatment; why scaling helps penalties in 5.3.01-Regularization-L1-L2-elastic-net; scaling before 6.2.01-Principal-Component-Analysis-PCA; and the network-internal cousin 7.1.03-Batch-normalization-in-neural-networks.