Randomly select vector with bounded norm

114 Views Asked by At

I would like to select randomly an $n$-dimensional real vector $\mathbf{x}=(x_1,\ldots,x_n)^\top\in\Bbb{R}^n$ such that its norm is bounded by a positive real number, say $\sqrt{a}$, $a\in\Bbb{R}_+$. In other words,

Select $\mathbf{x}\in\Bbb{R}^n$ such that $\lVert\mathbf{x}\rVert_2\leq\sqrt{a}$.

The simplest approach I have come up to is to uniformly draw each $x_i$ from $\left[-\sqrt{\frac{a}{n}}, \sqrt{\frac{a}{n}}\right]$, such that $$ -\sqrt{\frac{a}{n}}\leq x_i \leq\sqrt{\frac{a}{n}}\iff x_i^2\leq\frac{a}{n}, \quad\quad i=1,\ldots,n. $$ Then, $$ \sum_{i=1}^{n}x_i^2\leq a \iff \lVert\mathbf{x}\rVert_2^2 \leq a \iff \lVert\mathbf{x}\rVert_2\leq\sqrt{a}. $$ Is there any more sophisticated way for doing so?