# Algorithm to generate random points in n-Sphere?

I know this question already asked and actually well explained in those answers, just one thing that actually confuses be in other answers what if i want to generate random points on the surface of n-Sphere with radius r uniformly?

As according to one of the algorithm, generate n-dimensional vector $[x_1,x_2,..,x_n]$, where $x_i$ is random numbers using Normal Distribution N(0,1) and then use following formula to generate random point on the surface of n-Sphere

$$\frac{1}{\sqrt{x_1^2+x_2^2+... +x_n^2}}[x_1,x_2,...,x_n]$$

I presume that this will generate random points uniformly on the surface of unit n-Sphere, so what if we want generate random points on the surface n-Sphere with arbitrary radius r do we need to change the variance in Normal distribution or what?

Please forgive me if its a stupid question.

Regards Ahsan

• Just multiply the whole vector by $r$. – Rahul Jun 18 '14 at 23:31
• Can u elaborate a bit please? – Ahsan Iqbal Jun 19 '14 at 0:03
• Take the random vector on the unit $n$-sphere, $\frac1{\sqrt{x_1^2+\cdots+x_n^2}}[x_1,\ldots,x_n]$, and multiply it by $r$. – Rahul Jun 19 '14 at 2:19
• Rahul is right. $\frac{r}{\sqrt{x_1^2+\cdots+x_n^2}}[x_1,\ldots,x_n]$ is a random vector on the $n$-sphere with radius $r$. – mike Jun 19 '14 at 14:00
• Please link the relevant related questions – leonbloy Jun 19 '14 at 14:25

Take the random vector on the unit $n$-sphere, $$\frac{1}{\sqrt{x_1^2+...+x_n^2}}[x_1,...,x_n]$$ and multiply it by $r$.