What is the purpose of standardization in machine learning? I'm just getting started with learning about K-nearest neighbor and am having a hard time understanding why standardization is required. Reading through, I came across a section saying


  When independent variables in training data are measured in different
  units, it is important to standardize variables before calculating
  distance. For example, if one variable is based on height in cms, and
  the other is based on weight in kgs then height will influence more on
  the distance calculation.


Since K nearest neighbor is just a comparison of distances apart, why does it matter if one of the variables has values of a larger range since it is what it is.

Considering 3 points A,B &amp; C with x,y co-ordinates (x in cm, y in grams) A(2,2000), B(8,9000) and C(10,20000), the ranking of the points as distance from origin for example (or any other point), will be the same whether the y values are in grams,pounds, tonnes or any other combinations of units for both x and y so where's the need to standardise. Every example or QA i see brushes through with the same statement of 'one variable influencing the other' without a real example of how this might occur. Again, how does one know when this influence is too much as to call for standardization.

Also,what exactly does standardization do to the values? One of the formulas does it by Xs = (X-mean)/(max-min) Where does such a formula come from and what is it really doing? Hopefully someone can offer me a simplified explanation or give me a link to a site or book that explains this in simple terms for beginners.
Considering 3 points A,B &amp; C with x,y co-ordinates (x in cm, y in
  grams) A(2,2000), B(8,9000) and C(10,20000), the ranking of the points
  as distance from origin for example (or any other point), will be the
  same whether the y values are in grams,pounds, tonnes or any other
  combinations of units for both x and y so where's the need to
  standardise.


This is true for the example you provided, but not for euclidean distance between points in general. Look at this example:

def euclidian_distance(a, b):
    return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5

a1 = 10   #10 grams
a2 = 10  #10 cm
b1 = 10   #10 gram
b2 = 100  #100 cm
c1 = 100  #100 gram
c2 = 10   #10 cm 

# using (grams, cm) 
A_g_cm = [a1, a2]
B_g_cm = [b1, b2]
C_g_cm = [c1, c2]

print('[g, cm] A-B:', euclidian_distance(A_g_cm, B_g_cm))
print('[g, cm] A-C:', euclidian_distance(A_g_cm, C_g_cm))

# using (kg, cm) 
A_kg_cm = [a1/1000, a2]
B_kg_cm = [b1/1000, b2]
C_kg_cm = [c1/1000, c2]

print('[kg, cm] A-B:', euclidian_distance(A_kg_cm, B_kg_cm))
print('[kg, cm] A-C:', euclidian_distance(A_kg_cm, C_kg_cm))

# using (grams, m) 
A_g_m = [a1, a2/100]
B_g_m = [b1, b2/100]
C_g_m = [c1, c2/100]

print('[g, m] A-B:', euclidian_distance(A_g_m, B_g_m))
print('[g, m] A-C:', euclidian_distance(A_g_m, C_g_m))

# using (kilo, m) 
A_kg_m = [a1/1000, a2/100]
B_kg_m = [b1/1000, b2/100]
C_kg_m = [c1/1000, c2/100]

print('[kg, m] A-B:', euclidian_distance(A_kg_m, B_kg_m))
print('[kg, m] A-C:', euclidian_distance(A_kg_m, C_kg_m))


Output:

[g, cm] A-B: 90.0
[g, cm] A-C: 90.0
[kg, cm] A-B: 90.0
[kg, cm] A-C: 0.09000000000000001
[g, m] A-B: 0.9
[g, m] A-C: 90.0
[kg, m] A-B: 0.9
[kg, m] A-C: 0.09000000000000001


Here you can clearly see that the choice of units influence the ranking, thus the need for standardization.