# Average absolute value of a coordinate of a random unit vector?

Let $\vec x$ be a random unit vector (that is, a random vector on the unit sphere). Let $x_i$ be the $i$'th coordinate (if it is easier, you can assume we are in 3-dimensional space). What is the distribution of $|x_i|$? More specifically, what is the expected value $\langle|x_i|\rangle$?

• Assuming a uniform distribution, the answer can be read off the solutions at stats.stackexchange.com/questions/85916/… or stats.stackexchange.com/a/169818/919: ultimately it involves evaluating the first absolute moment of a symmetric Beta distribution, which doesn't involve any more than knowing the normalizing constants of Beta distributions (values of the Beta function). – whuber Oct 2 '17 at 14:45

This problem has a very nice geometrical interpretation if we can assume that the distribution $f(\vec{x})$ is constant over the surface of the $n-1$-unit-sphere in $n$-dimensional space. Then $f(\vec{x} \wedge (\vert x_i \vert=a))$ relates to the surface of two slices (at negative and positive coordinate) of the n-1 sphere in n-dimensional space, which is a (n-2)-dimensional sphere with radius $r = \sqrt{1-a^2}$.

The area of this slice is related to the area (or more like a length, since it is a curve) $A_{n-2}$ of the n-2 sphere multiplied with the distance $ds$ which is perpendicular to $\vec{r}$. The fraction of this slice must be related to the total, thus we use the ratio with the area of a $A_{n-1}$ sphere.

We have the area of the slice:

$$A_{slice} = A_{n-2}(r) ds$$

And the relative area of the slice is:

$$\frac{A_{slice}}{A_{total}} = \frac{A_{n-2}(r)}{A_{n-1}(1)} ds$$

with

$$A_{n-2}(r) = \frac{2\pi^{\frac{n-1}{2}}}{\Gamma\left(\frac{n-1}{2}\right)}r^{n-2}$$

$$A_{n-1}(1) = \frac{2\pi^{\frac{n}{2}}}{\Gamma\left(\frac{n}{2}\right)}$$

$$r = \sqrt{1- x_i ^2}$$

$$\begin{array} \\ds &= \sqrt{(dr)^2+(dx_i)^2}\\ %% &= \sqrt{\left(dx_i \frac{-x_i}{\sqrt{1-x_i^2}}\right)^2+(dx_i)^2}\\ %% &= \sqrt{(dx_i)^2 \frac{x_i^2}{{1-x_i^2}}+(dx_i)^2}\\ %% &= \sqrt{(dx_i)^2 \frac{1}{{1-x_i^2}}}\\ &= dx_i {\frac{1}{\sqrt{1-x_i^2}}} \end{array}$$

Thus:

$$\begin{array}\\ f(\vert x_i \vert) &= \frac{2 \Gamma\left(\frac{n}{2}\right)/\Gamma\left(\frac{n-1}{2}\right)}{\pi^{1/2}}\left(1-x_i^2\right)^{\frac{n-3}{2}}\end{array}$$

using the Beta function

$$\begin{array}\\ f(\vert x_i \vert) &= \frac{\left(1-x_i^2\right)^{\frac{n-3}{2}}}{B(\frac{1}{2},\frac{n-1}{2})} \end{array}$$

which becomes for n=3:

$f(\vert x_i \vert) = 1$

Which makes sense, intuitively. At the pole the slice has smaller radius but is thicker and at the equator the slice has larger radius but is more thin. This results in equal probability, whatever $x_i$ at the pole, the equator, or in between.

Note, some help about the intuition behind the integration step: The n-1 sphere in n-dimensional space is a hypersurface and intersection with $\vert x_i\vert=a$ is a hypercurve. By integrating the hypercurve, along the direction $\vec{s}$, you get the hypersurface

• I think the factor of two does not go there. This integrates to 2 ($x_i$ goes from 0 to 1), instead of 1. – becko Oct 2 '17 at 9:53
• You are right about the 2. But i made a larger error by using A_n = integral A_n-1(r) dr. I will correct it. – Martijn Weterings Oct 2 '17 at 10:12
• Thanks! I confirmed the uniform distribution of a coordinate in three dimensions by sampling unit vectors in Mathematica. Is there a book or paper that I can cite with this result? – becko Oct 2 '17 at 12:40
• I do not know any reference that you can use for this result. But it may be considered a bit trivial. So, in my opinion, in whatever report you are writing, you can simply state this result without an "official" source. Here is a piece of code for R that you can use to model in many dimensions: n <- 10; p <- 100000; x <- sapply(1:n, FUN = function(k) rnorm(p,0,1)); x_1 <- x[,1]/sqrt(rowSums(x^2)); plot(hist(abs(x_1), nclass=50)); lines(seq(0,1,0.001),p/50*2*gamma(n/2)/gamma((n-1)/2)/sqrt(pi)*(1-seq(0,1,0.001)^2)^(0.5*(n-3)),col=3); – Martijn Weterings Oct 2 '17 at 14:01
• They are the same in the expression with gamma functions. Do you mean it is also the same when we write it in terms of binomial coefficients? edit: ah I see, the factorial case is the same. – Martijn Weterings Oct 2 '17 at 19:46

The answer is $1/2$

This paper has the probability density $f_n(x_i)$ of $x_i$ for the vector inside an n-dimensional hypersphere. You're interested in the vector from origin to the random point on a surface of a hypersphere. To get the surface of a unit hypersphere you simply take a derivative along the radius then fix the radius at 1.

Therefore, you can use $2f_{n-2}(x_i)$ from the paper as a density for your problem and take an integral from 0 to 1: $$\int_0^1 2f_{n-2}x dx=\int_0^1 f_{n-2} dx^2$$

The equations for $f_n$ from the paper: $$\frac{\Gamma(n/2+1)}{\Gamma((n+1)/2)}\frac{(\sqrt{1-x^2})^{n-1}}{\sqrt\pi}$$

Hence, the density of the $|x_i|$ is given by: $$\tilde f_n(|x|)=2\frac{\Gamma((n-2)/2+1)}{\Gamma((n-1)/2)}\frac{(\sqrt{1-x^2})^{n-3}}{\sqrt\pi}$$

For three dimensional case you get: $$\tilde f_3(|x|)=\frac{2\Gamma(3/2)}{\sqrt\pi}=1$$

You get the mean absolute value by integrating: $$\int_0^1\tilde f_3(|x|)xdx=\int_0^1xdx=1/2$$

Two points worth noting. First, it's easy to calculate the integral for any $n$ by substitution $z=x^2$ : $$\frac{2 \Gamma(\frac n 2)}{(n-1)\Gamma(\frac{n-1}{2})\sqrt\pi}$$ You can see now that the average absolute value of the coordinate converges to zero as dimensionality increases as shown on the plot of the average vs. $n$ number of dimensions:

Second, the sequence of functions on these densities converges to the normal distribution: $$\frac{f_n(v/\sqrt{n+2})}{\sqrt{n+2}}\to_{n\to\infty}\mathcal{N}(0,1)$$

• By taking the derivative of the volume, we get to the surface area. But how does this allow us to use the density $f_{n}(x)$ from the paper, by just changing the dimension from $n-1$ to $n-2$? In comparison, the formula for volume and surface area, are not simply different by the dimension factor. Of course, this $f_n$ from the paper, is the same density, with just 1 difference in the dimension. But, I wonder about the argumentation in the first paragraph. – Martijn Weterings Oct 2 '17 at 19:07
• If we follow the logic of the article, $V_n = \int_{-1}^1 V_{n-1} \left( \sqrt{1-x^2} \right)^{n-1} dx$, then we get for surface a similar equation: $A_n = \int_{-1}^1 A_{n-1} \left( \sqrt{1-x^2} \right)^{n-3} dx$. Which is one way to connect the expression of the paper, for volumes, to surfaces with just a difference in the parameter $n$. – Martijn Weterings Oct 2 '17 at 19:33
• @MartijnWeterings, yes, the volume of a sphere is the sum of surfaces of smaller spheres, like a Russian Matreshka doll. I'm trying to come up with a more direct explanation. It's clear to me but now I see that my exposition may have been puzzling to a reader – Aksakal Oct 2 '17 at 19:40