[Math] How to derive euclidean distance matrix from gram-schmidt matrix

linear algebramatrix-calculus

This is my first post, sorry for my naiveness..

I know a basic equation that relates Gram-schmidt matrix and Euclidean distance matrix:

$XX'=-0.5*(I-J/n)*D*(I-J/n)'$

Where $X$ is centered data (is $d \times n$), $I$ is identity matrix, $J$ is a matrix filled with ones (1), $n$ is the number of columns in $X$, and $D$ is the distance matrix (with dimensions $n \times n$).

My question is:

How can I derive Euclidean distance matrix $D$ from this equation? I would like something like:

$D=$ (something ¿?)

For example, I can see that:

$D=-2*inv((I-J/n))*XX'*inv((I-J/n)'$

But $(I-J/n)$ is a singular matrix. I am still interested in some approximation.

Thanks a lot!!

Mark

Best Answer

There are simple linear relationships between an Euclidean distance matrix and a Gramian matrix in both directions. The linear transformation $G\rightarrow D$ is given by $$ D = \delta(G)\mathbf{1}^\mathrm{T} + \mathbf{1}\delta(G)^\mathrm{T} - 2G,$$ where $G=XX^\mathrm{T}$, and $\delta(G)$ denotes the diagonal elements of $G$.

Your formula for $G\rightarrow D$ may also be rewritten as $$ G = -\frac{1}{2}VDV,$$ where $V=I_n-\frac{1}{n}\mathbf{1}\mathbf{1}^\mathrm{T}$ is a geometric centering matrix.