# Sampling vector so they will have a given euclidean distances matrix

Given a matrix $M\in\mathbb{R}^{P\times P}$ , is it possible to sample $P$ vectors $u_i\in\mathbb{R}^N$, $i=1..P$ so that $\|u_i-u_j\|=M_{ij}$.

Obviously for not any $M$ this is possible, i.e. it has to be symmetric, have zero diagonal, etc., but assume $M$ was created from a different set of vectors which satisfied this property.

• Do you have a specific distribution you have in mind? There's obviously translation and rotational invariances, but there could be multiple solutions sans those invariances... – Memming Nov 26 '15 at 16:03

Multidimensional scaling (MDS) is one algorithm that tries to find such a set of points. It's usually used for visualization, so it's usually used in 2 or 3D spaces, but the optimization procedure itself can be used in arbitrary dimensions.

To get random samples, you can initialize with random vectors before optimizing, though it is not clear what distribution you'd be sampling from in this case.

EDITED: Sample MATLAB code to generate $P$ patterns of size $N$ with the same distances as a reference data:

data=mdscale(pdist(reference_data), N, 'Start', 'Random');


or using an Euclidean distances matrix D of size $P\times P$:

data=mdscale(D, N, 'Start', 'Random');