Why Scale Matters for Distance
When a method compares observations by their distance, the units used to record predictors can affect the comparison. A difference of 5 might be large for a variable measured in years but small for a variable measured in thousands of dollars. If the raw numbers are used directly, the distance calculation does not know what counts as a meaningful difference in context.
This matters whenever a method uses distances between predictor vectors, such as a nearest-neighbor procedure or a distance-based clustering method. The central issue is geometric: Euclidean distance combines coordinate differences, so a predictor with numerically large differences can dominate the result. That dominance may reflect the choice of units rather than a deliberate judgment about the predictor's importance.
The square root turns the sum of squared differences back into the units of the coordinates when those coordinates share a common unit. With predictors measured in different units, the result is still a numerical distance, but its value and the relative influence of the predictors depend on how those units are represented. A numeric code for a category should not automatically be treated as a meaningful coordinate: Euclidean distance assumes that differences between numeric values have interpretable size.
How Rescaling Changes Distance
Suppose just predictor \(j\) is rescaled by multiplying every value by a constant \(c\). For a pair of observations, the difference in that coordinate becomes \(c(x_j-z_j)\). Its contribution to squared distance therefore becomes \(c^2(x_j-z_j)^2\). If \(c\) is large, that coordinate receives more weight in the distance; if \(c\) is small, it receives less.
This result follows directly from substituting the transformed coordinate into the definition of Euclidean distance. If \(x'_j=cx_j\) and \(z'_j=cz_j\), then $$ (x'_j-z'_j)^2=(cx_j-cz_j)^2=c^2(x_j-z_j)^2. $$ The other coordinates have not changed, so their squared differences remain as before. This is why changing one predictor's units can change not only the numerical distances but also the ordering of which observations are closest.
A change of units often also includes adding a constant, as when converting a temperature scale. For a translation \(x'_j=cx_j+b\), the difference is \(x'_j-z'_j=c(x_j-z_j)\): the added constant \(b\) cancels. Thus translation alone does not affect pairwise distances, while multiplication by \(c\) does. If every coordinate is multiplied by the same nonzero constant, every distance is multiplied by its absolute value, so the nearest-observation ranking is preserved. Rescaling only one coordinate generally does not preserve that ranking.
Worked Examples
Worked Example: Age and Annual Travel Distance
A hypothetical analyst compares three policyholders using age in years and annual travel distance in kilometers. A query policyholder has values \((40,12000)\). Candidate A has values \((42,11000)\), and candidate B has values \((48,12100)\). Calculate the raw Euclidean distances and identify the closer candidate. Then repeat after expressing annual travel distance in thousands of kilometers.
Method. Apply Euclidean distance to the two numeric predictors. First calculate the coordinate differences in their recorded units:
For A, the differences from the query are \(42-40=2\) years and \(11000-12000=-1000\) kilometers. Therefore, $$ d_A=\sqrt{2^2+(-1000)^2} =\sqrt{4+1000000} =\sqrt{1000004} \approx 1000.002. $$
For B, the differences are \(48-40=8\) years and \(12100-12000=100\) kilometers. Therefore, $$ d_B=\sqrt{8^2+100^2} =\sqrt{64+10000} =\sqrt{10064} \approx 100.319. $$
On the raw scale, B is closer because \(100.319<1000.002\). Now divide every travel-distance value by 1000, so the travel-distance coordinate is in thousands of kilometers. The query becomes \((40,12)\), A becomes \((42,11)\), and B becomes \((48,12.1)\). The resulting distances are $$ d_A^*=\sqrt{2^2+(-1)^2}=\sqrt{5}\approx 2.236, \qquad d_B^*=\sqrt{8^2+0.1^2}=\sqrt{64.01}\approx 8.001. $$
On this rescaled representation, A is closer. The change in ranking is the point: the raw calculation gave travel distance, recorded in kilometers, a very large numerical contribution. Changing its unit altered its contribution to squared distance by a factor of \(1/1000^2\). Common mistake avoided: treating the raw-scale ranking as evidence that B is unambiguously more similar, without noticing that one coordinate was recorded in much larger numerical units.
Worked Example: A Ranking Reversal Under a Unit Conversion
A hypothetical equipment-screening model compares devices by operating time in hours and vibration in millimeters per second. The query device is \((10,0)\). Device P is \((11,8)\), and device Q is \((13,2)\). Find the nearest device using these recorded values, then convert vibration to centimeters per second by dividing that coordinate by 10 and recalculate.
Method. On the original scale, the distances are $$ d_P=\sqrt{(11-10)^2+(8-0)^2} =\sqrt{1+64} =\sqrt{65} \approx 8.0623, $$ $$ d_Q=\sqrt{(13-10)^2+(2-0)^2} =\sqrt{9+4} =\sqrt{13} \approx 3.6056. $$
Thus Q is nearer using vibration in millimeters per second. After conversion, the query is \((10,0)\), P is \((11,0.8)\), and Q is \((13,0.2)\). The distances become $$ d_P^*=\sqrt{1^2+0.8^2} =\sqrt{1.64} \approx 1.2806, \qquad d_Q^*=\sqrt{3^2+0.2^2} =\sqrt{9.04} \approx 3.0067. $$
Now P is nearer. The conversion divides the vibration differences by 10, so it divides that coordinate's squared contribution by 100. This is a change in the geometry used by the method, not a change to the devices themselves. Common mistake avoided: assuming a unit conversion must leave all nearest-neighbor rankings unchanged. It leaves the ranking unchanged only if all coordinates are scaled by the same absolute factor, or if the particular data happen not to produce a reversal.
Worked Example: Comparing Distances After Z-Score Scaling
A hypothetical credit review compares age and account balance. A query has age 40 years and balance of 60 thousand dollars. Candidate A has age 42 and balance 70 thousand dollars; candidate B has age 46 and balance 62 thousand dollars. For this comparison, use a reference mean age of 40 years and standard deviation of 5 years, and a reference mean balance of 60 thousand dollars and standard deviation of 20 thousand dollars. Calculate the Euclidean distances after converting each predictor to a z-score, and identify the nearer candidate.
Method. For a predictor with reference mean \(\bar{x}\) and standard deviation \(s\), its z-score is \(z=(x-\bar{x})/s\). The query has z-scores \((0,0)\). Candidate A has z-scores $$ \left(\frac{42-40}{5},\frac{70-60}{20}\right)=(0.4,0.5), $$ and candidate B has z-scores $$ \left(\frac{46-40}{5},\frac{62-60}{20}\right)=(1.2,0.1). $$
The distances from the query are $$ d_A=\sqrt{0.4^2+0.5^2} =\sqrt{0.16+0.25} =\sqrt{0.41} \approx 0.6403, $$ $$ d_B=\sqrt{1.2^2+0.1^2} =\sqrt{1.44+0.01} =\sqrt{1.45} \approx 1.2042. $$
A is nearer under these specified reference scales. The calculation expresses each difference in standard-deviation units, so a one-unit difference on the transformed age coordinate represents 5 years, while a one-unit difference on the transformed balance coordinate represents 20 thousand dollars. Common mistake avoided: presenting the result as a scale-free truth. The choice of reference scales affects the comparison, so the analyst must be able to explain why those scales suit the task. Distances are rounded to four decimal places.
Interpreting Scale and Choosing a Comparison
The arithmetic explains how scale operates, but it does not determine which scaling is appropriate. A predictor with a large numerical range should not automatically receive a large influence simply because its values use larger numbers. Conversely, equalizing scales is not automatically correct if the problem calls for one predictor to have more influence. Scaling encodes a choice about how differences across predictors should count in the distance calculation.
For example, a difference of one year and a difference of one thousand dollars cannot be compared by their numerical sizes alone. The analyst needs to decide what constitutes a meaningful difference for the application. One option is to express predictors on comparable scales, such as by using the z-score transformation described in the worked example. Any resulting distances then depend on the reference values used to define those scales.
Keep three distinctions clear:
- Changing units: multiplying a predictor by a constant changes its contribution to squared Euclidean distance, even though the underlying observations are unchanged.
- Changing every coordinate equally: multiplies all distances by the same absolute constant and preserves their ranking.
- Changing only some coordinates: changes the relative influence of predictors and may change which observations are nearest.
A common exam trap is to interpret a small raw distance as evidence of close similarity without checking the measurement units. A related error is to claim that scaling always improves a model. Scaling changes the distance calculation; whether that change is appropriate depends on the modeling purpose and the meaning of the predictors. The calculation should therefore be explained in context, not treated as a neutral formatting step.
Check Your Understanding
For each problem, state the relevant distance comparison and attend to the effect of the specified scale change.
- A query has coordinates \((3,40)\). Candidate P is \((4,38)\), and candidate Q is \((5,41)\). Calculate both Euclidean distances and state whether either candidate is nearer. (Answer: Both distances are \(\sqrt{5}\approx 2.2361\); they are tied.)
- A query is \((0,0)\); candidates A and B are \((1,8)\) and \((3,2)\). Calculate the distances, then divide the second coordinate of every vector by 10 and recalculate. State whether the ranking changes. (Answer: Initially, \(d_A=\sqrt{65}\approx 8.0623\) and \(d_B=\sqrt{13}\approx 3.6056\), so B is nearer. After rescaling, \(d_A=\sqrt{1.64}\approx 1.2806\) and \(d_B=\sqrt{9.04}\approx 3.0067\), so A is nearer.)
- Two observations have difference vector \((3,4)\). Find their Euclidean distance. If both coordinates are multiplied by 4, find the new distance and explain why their relative ordering against other pairs would be preserved if every pair were transformed the same way. (Answer: The original distance is \(\sqrt{3^2+4^2}=5\); the new distance is \(20\). All distances are multiplied by 4, preserving their ordering.)
- A query is \((10,100)\). Candidate A is \((12,110)\), and candidate B is \((14,105)\). Use predictor standard deviations of 2 and 5, respectively, to calculate the z-score distances from the query and identify the result. (Answer: A has distance \(\sqrt{1^2+2^2}=\sqrt{5}\approx 2.2361\); B has distance \(\sqrt{2^2+1^2}=\sqrt{5}\approx 2.2361\). They are tied.)
- A candidate differs from a query by 2 units on predictor 1 and 3 units on predictor 2. Predictor 2 is then multiplied by 5, while predictor 1 is unchanged. Calculate the old and new distances, and state the factor by which predictor 2's squared contribution changes. (Answer: The old distance is \(\sqrt{2^2+3^2}=\sqrt{13}\approx 3.6056\); the new distance is \(\sqrt{2^2+15^2}=\sqrt{229}\approx 15.1327\). Predictor 2's squared contribution increases by a factor of \(5^2=25\).)