Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I've seen many different approaches to generate a random vector in the ($n-1$)-sphere and in the $n$-ball. One of them is generating a normal n-vector v (all components $x_i\sim N(0,1)$) and then normalizing the vector. For some weird reason I cannot quite understand this vector is uniformly distributed in the ($n-1$)-sphere. For the inside of the $n$-ball I choose a random uniform $u\sim U(0,1)$ and then multiply $v \cdot \sqrt[n]{u}$.

Now I need to generate a uniform n-vector inside an $n$-ring (the volume between two $n$-balls of radio $r_1$ and $r_2$). I did it by generating a $u\sim U(a,b)$ such that $\sqrt[n]{a} = r_1$ and $\sqrt[n]{b} = r_2$, and follow the same approach as before.

My question is: Is this correct, or is there another better (and/or faster) method for this?

I'll be generating many of these vectors in some high dimension ($> 1000$) for a meta-heuristic. Thanks in advance.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.