[SciPy-user] Carateristic distance in a cloud of points
Sat Feb 24 13:42:00 CST 2007
I have a cloud of points (for instance given as a (n,3) shaped array,
with columns formed by the x, y and z column vectors).
I would like to find the mean distance in this cloud of points. I do not
need an exact value, I am just interested in a typical distance.
I could do it in a brute force way:
from scipy import *
x = arange(1, 5)
points = c_[x, x, x]
diffs = abs(points[newaxis, :] - points[:, newaxis])
dists = sqrt(diffs[..., 0]**2 + diffs[..., 1]**2 + diffs[..., 2]**2).ravel()
dists = dists[dists>0]
This is actually not as ugly and slow as I originaly thought.
Are there any better ways of doing this ?
More information about the SciPy-user