# What is the distribution of the Euclidean distance between two normally distributed random variables?

Assume you are given two objects whose exact locations are unknown, but are distributed according to normal distributions with known parameters (e.g. $a \sim N(m, s)$ and $b \sim N(v, t))$. We can assume these are both bivariate normals, such that the positions are described by a distribution over $(x,y)$ coordinates (i.e. $m$ and $v$ are vectors containing the expected $(x,y)$ coordinates for $a$ and $b$ respectively). We will also assume the objects are independent.

Does anyone know if the distribution of the squared Euclidean distance between these two objects is a known parametric distribution? Or how to derive the PDF / CDF for this function analytically?

• You should obtain a multiple of a non-central chi-squared distribution provided all four coordinates are uncorrelated. Otherwise, the result looks much more complicated. – whuber Apr 5 '11 at 20:45
• @whuber any details/pointers you could provide as to how the parameters of the resulting non-central chi-squared distribution relate to those of the objects a, b would be fantastic – Nick Apr 5 '11 at 22:09
• @Nick the first few paragraphs of the Wikipedia article provide the details. By looking at the characteristic functions you can establish that a similar result is not available when not all variances are the same or there are some correlations. – whuber Apr 5 '11 at 22:13
• @Nick, just to clarify, both $a$ and $b$ are random vectors with values in $\mathbb{R}^2$? – mpiktas Apr 6 '11 at 13:01
• @Nick, if $a$ and $b$ are jointly normal, then the difference is $a-b$ is normal too. Then your problem is to find distribution of random normal vector. Googling I found this link. The paper describes much more complex problem which in very particular case coincides with yours. This gives some hope that there is a definite answer to your question. References might give you further ideas where to search. – mpiktas Apr 6 '11 at 13:15

The answer to this question can be found in the book Quadratic forms in random variables by Mathai and Provost (1992, Marcel Dekker, Inc.).

As the comments clarify, you need to find the distribution of $Q = z_1^2 + z_2^2$ where $z = a - b$ follows a bivariate normal distribution with mean $\mu$ and covariance matrix $\Sigma$. This is a quadratic form in the bivariate random variable $z$.

Briefly, one nice general result for the $p$-dimensional case where $z \sim N_p(\mu, \Sigma)$ and
$$Q = \sum_{j=1}^p z_j^2$$ is that the moment generating function is $$E(e^{tQ}) = e^{t \sum_{j=1}^p \frac{b_j^2 \lambda_j}{1-2t\lambda_j}}\prod_{j=1}^p (1-2t\lambda_j)^{-1/2}$$ where $\lambda_1, \ldots, \lambda_p$ are the eigenvalues of $\Sigma$ and $b$ is a linear function of $\mu$. See Theorem 3.2a.2 (page 42) in the book cited above (we assume here that $\Sigma$ is non-singular). Another useful representation is 3.1a.1 (page 29) $$Q = \sum_{j=1}^p \lambda_j(u_j + b_j)^2$$ where $u_1, \ldots, u_p$ are i.i.d. $N(0, 1)$.

The entire Chapter 4 in the book is devoted to the representation and computation of densities and distribution functions, which is not at all trivial. I am only superficially familiar with the book, but my impression is that all the general representations are in terms of infinite series expansions.

So in a certain way the answer to the question is, yes, the distribution of the squared euclidean distance between two bivariate normal vectors belongs to a known (and well studied) class of distributions parametrized by the four parameters $\lambda_1, \lambda_2 > 0$ and $b_1, b_2 \in \mathbb{R}$. However, I am pretty sure you won't find this distribution in your standard textbooks.

Note, moreover, that $a$ and $b$ do not need to be independent. Joint normality is enough (which is automatic if they are independent and each normal), then the difference $a-b$ follows a normal distribution.

• Thanks for the reference, I found the book and am slowly trying to make my way through it – Nick Jun 21 '11 at 23:58
• @NRH I've worked through the MGF myself in the symmetric case ($\lambda_j = \sigma^2$) where $p=2$ and instead of $b_j^2 \lambda_j$ in the summation, I have $\mu_j^2$. Simulation verifies the first moment. It's possible that this is the "linear function" you mention and that this is peculiar to the symmetric case, but I thought I'd point it out in case there's an error. – kyle Feb 28 '14 at 20:48
• Actually, based on their definition of $b_j$, the numerator in the exponential does reduce to $\mu_j^2$ in the symmetric (independent dimensions with common variance) case. – kyle Mar 3 '14 at 23:57

First define the bivariate distribution of the difference vector, $\mu_d = \mu_1 - \mu_2$, which will be simply $\Sigma_d = \Sigma_1 + \Sigma_2$; this follows from the multivariate uncertainty propagation $\Sigma_d = \mathrm{J} \Sigma_{12} \mathrm{J}^T$, involving a block diagonal matrix $\Sigma_{12} = \begin{bmatrix} \Sigma_1 & \\ & \Sigma_2 \end{bmatrix}$ and the Jacobian $\mathrm{J} = \begin{bmatrix} +\mathrm{I}, & -\mathrm{I} \end{bmatrix}$ .

Secondly, look for the distribution of the difference vector length, or the radial distance from the origin, which is Hoyt distributed:

The radius around the true mean in a bivariate correlated normal random variable with unequal variances, re-written in polar coordinates (radius and angle), follows a Hoyt distribution. The pdf and cdf are defined in closed form, numerical root finding is used to find cdf^−1. Reduces to the Rayleigh distribution if the correlation is 0 and the variances are equal.

A more general distribution arises if you allow for a biased difference (shifted origin), from Ballistipedia: • +1, but I think it's worth pointing out that the question deals with what your figure calls the "General case". – amoeba Dec 5 '15 at 21:48

Why not test it out?

set.seed(347)
x <- rnorm(10000)
y <- rnorm(10000)
x2 <- rnorm(10000)
y2 <- rnorm(10000)

qdf <- data.frame(x,y,x2,y2)
qdf <- data.frame(qdf,(x-x2)^2+(y-y2)^2)
colnames(qdf) <- "euclid"

plot(c(x,y),c(x2,y2))
plot(qdf$euclid) hist(qdf$euclid)
plot(dentist(qdf\$euclid))    • whubers comments to the original question already stated what it would look like if the variances were the same and the variables were uncorrelated. Perhaps giving an example of where this is not the case would be more enlightening. – Andy W Apr 12 '11 at 15:51
• Can you provide such an example? – Brandon Bertelsen Apr 13 '11 at 4:50
• all you need to do is generate the x and y values that are either correlated or have different variances. The different variances could be done right in the code as is. You could generate values from a specified covariance matrix using mvrnorm from the MASS package. Also I am not sure what the function "dentist" is in the above code, should it perhaps be "density". – Andy W Apr 13 '11 at 12:47
• That being said it is probably just as enlightening to work through the math to see why this is the case (and how manipulating the variance/covariances will change the distribution). It is not entirely clear for me why this is the case just by looking at the characteristic function mentioned by whuber. It looks like though a simple understanding of rules for adding, subtracting, and multiplying random variables will get you along way to understanding why that is. – Andy W Apr 13 '11 at 13:03