# Sampling uniformly from n-sphere using spherical coordinates

It has been explained here why sampling from n-sphere is not achievable with naive parametrization. And it explains how to correct it for 3 dimensions. Can somebody please guide me what is the correct method for uniformly sampling in n dimensions using the spherical coordinates? i.e. \begin{align} &x_1 = r \cos(\phi_1) \,\\ &x_2 = r \sin(\phi_1) \cos(\phi_2) \,\\ &x_3 = r \sin(\phi_1) \sin(\phi_2) \cos(\phi_3) \,\\ &{}\,\,\,\vdots\\ &x_{n-1} = r \sin(\phi_1) \cdots \sin(\phi_{n-2}) \cos(\phi_{n-1}) \,\\ &x_n = r \sin(\phi_1) \cdots \sin(\phi_{n-2}) \sin(\phi_{n-1}) \,. \end{align}

• Why do you want to do this via spherical coordinates instead of the more conventional way, as mentioned in your second link? – cardinal Nov 23 '13 at 19:03
• @cardinal Because actually I am not after sampling now(I will use it later when I need Monte Carlo methods). Right now I am dealing with the case of parametrization of a $n-1$-sphere to be able to assign probability to points on it. A uniform sampling method based on this parametrisation will provide me with one way to do so, right? – Cupitor Nov 23 '13 at 19:10
• The hypersphere is my parameter space. – Cupitor Nov 23 '13 at 19:14