Thursday, 2 November 2006

geometry - How to pick a random direction in n-dimensional space

The easiest way to do this efficiently is to rely on the fact that a gaussian distribution is spherically symmetric and also separable. So, what you need to do is :



1) Build a vector V where each element is a Gaussian distributed value of mean 0, choose any width that makes sense.



2) Normalize the vector V



This vector now is a random unit vector uniformly distributed across the hypersphere of the vector V. This algorithm is both fast and is linear in the dimension of V.

No comments:

Post a Comment