For a model I’ve been working on I needed to generate points (cluster centres) that were located equidistant from each other. Not a terribly hard problem, but I happen to come across this answer on mathoverflow that I found pretty neat. I readily admit that I don’t understand exactly how it works, but here is the equivalent julia code:
"""
Return the vertices of a regular simplex in `n` dimenions.
"""
function get_simplex_vertices(n)
q,r = qr(fill(1.0, n+1))
points = permutedims(q[:,2:end],[2,1])
#rescale so that the distance is 1
points ./= sqrt(2)
end
Just thought I’d put it out there in case anyone else finds it useful at some point.