Take $X$ uniform on the unit sphere in $\mathbb{R}^n.$ For $r>0$, take $S_r=\{x\in \mathbb{Z}^n: \sum_i x_i^2 \leq r^2\}.$

- With $\|\cdot \|$ the 2-norm, what is the distribution (or at least the mean) of:

\begin{align} \underset{x \in S_r}{\min} \ \left\|X-\frac{x}{\|x\|}\right\|^2 \end{align}

- How can this optimization be performed efficiently?

One idea for performing the optimization is by exhaustion: the point in $S_r$ that attains the minimum will be a nearest-integer rounding of a point on the ray $\alpha X$. The values $\alpha$ for which $\operatorname{round}(\alpha X)$ changes can be readily computed. Then choose the best value once $\alpha$ is small enough that $\alpha X$ rounds to zero. However I am not sure what the complexity of this is in general.