Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating random points on a surface of an n-dimensional torus

I'd like to generate random points being located on the surface of an n-dimensional torus. I have found formulas for how to generate the points on the surface of a 3-dimensional torus:

x = (c + a * cos(v)) * cos(u)
y = (c + a * cos(v)) * sin(u)
z = a * sin(v)

u, v ∈ [0, 2 * pi); c, a > 0.

My question is now: how to extend this formulas to n dimensions. Any help on the matter would be much appreciated.

like image 538
Tomasz Nguyen Avatar asked Nov 11 '22 00:11

Tomasz Nguyen


1 Answers

I guess that you can do this recursively. Start with a full orthonormal basis of your vector space, and let the current location be the origin. At each step, choose a point in the plane spanned by the first two coordinate vectors, i.e. take w1 = cos(t)*v1 + sin(t)*v2. Shift the other basis vectors, i.e. w2 = v3, w3 = v4, …. Also take a step from your current position in the direction w1, with the radius r1 chosen up front. When you only have a single basis vector remaining, then the current point is a point on the n-dimensional torus of the outermost recursive call.

Note that while the above may be used to choose points randomly, it won't choose them uniformly. That would likely be a much harder question, and you definitely should ask about the math of that on Math SE or perhaps on Cross Validated (Statistics SE) to get the math right before you worry about implementation.

like image 123
MvG Avatar answered Dec 03 '22 08:12

MvG