# How is the distance formula related to the formula for standard deviation

The formula for the standard deviation of n numbers is the same as the formula for the distance between two points in n dimensions. Could someone explain why this is and how these are related?

• +1, this is a neat question. I'm not sure about the denominator, though. If you're thinking of the population formula for the SD, then the denominator is $N$, which makes it something like the average Euclidean distance per dimension. If you're thinking of the sample formula, the denominator is $N-1$, which is a little weirder. Feb 21, 2013 at 2:32
• @gung there's not really a "the" sample formula. The $n-1$ form - the one that is unbiased for the variance (but not for the s.d.) - is easily the most common, for sure, but the $n$ form is also used, as are various other forms (such as MMSE for the variance at the normal, for example). Feb 21, 2013 at 3:31
• nobody likes my answer? Feb 21, 2013 at 3:32
• Practically the same question appears at stats.stackexchange.com/questions/118. @Benjamin, your reply does not appear to answer this question: it does not explain what might be special about the Euclidean distance as a measure of dispersion among data. It only seems to echo the observation made by the OP--namely that both formulas are the same. Indeed, it could easily leave the casual reader with the impression that there's nothing unique at all about the Euclidean distance or the SD.
– whuber
Feb 21, 2013 at 8:30

Any set in which you can define a 'distance' function which satisfies a few properties (distances are positive, symmetric, and additive). Is called a Metric space. $\mathbb{R}^k$ is a metric space with the distance function typically defined to be $d(\mathbf{x},\mathbf{y}) = |\mathbf{x}-\mathbf{y}|$, the norm of the difference (although we can use whatever distance function we want as long as it satisfies the 3 properties, more on that later).
The norm is defined to be $|\mathbf{x}| = \sqrt{\sum_{i=1}^n x_i^2}$. That right there looks strangely familiar you might think. So if you have some observed values $\mathbf{x}=x_1,\ldots,x_n$ and if we find the distance between your observed values and their mean, $\mu$ we have $d(\mathbf{x},\mu) = |\mathbf{x}-\mu| = \sqrt{\sum_{i=1}^n (x_i-\mu)^2}$ which is almost like the standard deviation (missing a $1/n$ or $1/(n-1)$. However, we can easily redefine our distance function to be something like $d(\mathbf{x},\mathbf{y}) = +\sqrt{1/n}|\mathbf{x}-\mathbf{y}|$ and it will still have the three properties required to make $\mathbb{R}^k$ a metric space.
You might be more familiar with distances in a 2-dimensional space like $\mathbb{R}^2$. In this space we can use the same distance function as above, but since instead of $k$ components we have only 2 the formula simplifies to $d((x_1,y_1), (x_2,y_2)) = \sqrt{(x_1-x_2)^2+(y_1-y_2)^2}$
• Wouldn't $\mu$ be multi-dimensional here though? Matching the same number of dimensions as the vector $\mathbf{x}$? That's where it seems like the difference lies between the two formulas... distance is a scalar, which is what seems to destroy the idea of std. deviation being the same as distance. I'm not smart at stats, so I could be wrong here. Jun 30, 2021 at 16:50
• Just use $\mathbf{\mu} = (\mu,\ldots,\mu)$ a vector of same length as $\mathbf{x}$ with all the same entries Jul 6, 2021 at 14:45