# Covariance of a set of uniformly distributed unit vectors?

I have a set of uniformly distributed unit vectors within a "cone" (essentially a subset of a uniform distribution on the unit sphere, as described here). I've found how to get the covariance matrix for a uniform spherical distribution, but I'm having trouble applying that to my problem (that is, how do I go from the covariance for a uniform distribution over the whole sphere to that for a subset of the unit sphere?). Can anyone describe how I would go about doing this, or at least point me in the right direction?

Thanks!

edit: I would prefer the covariance matrix in spherical coordinates, although I suppose I could make Cartesian work for my application as well.

• Of what would you like the covariance matrix? The spherical coordinates? The Cartesian coordinates? Something else? And what is the base of this cone--is it a circle or is it a more general shape?
– whuber
May 6 '13 at 16:57
• Edited the post to say my preference in coordinate system. As to the shape of the cone... just a circular base. Think a polar cap, but rotated to a general direction. May 6 '13 at 17:13

The solution is straightforward in Cartesian coordinates and impossibly messy in spherical coordinates. I will describe it for a cone that fits within a hemisphere; larger cones can be treated in a similar manner.

Choose units in which the sphere has unit radius. After a suitable rotation by some orthogonal matrix $\mathbb{Q}$, the cone will be vertical and projects onto a circle of radius $\rho$ in the xy plane. In cylindrical coordinates $(r, \theta, z)$, the points will have a uniform distribution in $\theta$ between $0$ and $2\pi$ (by cylindrical symmetry), a uniform distribution in $z$ between $\sqrt{1-\rho^2}$ and $1$, and necessarily $r = \sqrt{1-z^2}$.

Because $z$ has a uniform distribution, its variance is

$$(1 - (1-\rho^2))/12 = \rho^2/12.$$

The distribution of $r$ is deduced from that of $z$ by taking the Jacobian; its pdf is

$$\frac{r}{\sqrt{1-r^2} (1 - \sqrt{1-\rho^2})}, \quad 0 \le r \le \sqrt{1-\rho^2}.$$

By axial symmetry the expectations of $x$ and $y$ are both zero, whence their variances are the expectations of their squares. By the reflection symmetry $x\to y$, $y\to x$, these expectations are equal. The sum of those expectations is the expectation of $x^2+y^2 = r^2$, which can be computed as

$$\int_0^{\rho } \frac{ r^2 \, rdr}{\left(1-\sqrt{1-\rho ^2}\right) \sqrt{1-r^2}} = \frac{2- \left(2+\rho ^2\right)\sqrt{1-\rho ^2} }{3(1-\sqrt{1-\rho ^2})}.$$

Half of this quantity therefore is the common variance of $x$ and $y$. (As a quick check, the limiting values of the $x$ and $y$ covariances at $\rho\to 1$ are $1/3$. This is correct, because the variance of $x$ for the upper hemisphere equals the variance of $x$ for the sphere, which clearly is $1/3$.)

The symmetries $x\to -x$ and $y\to -y$ immediately imply the covariances among $x$, $y$, and $z$ are all $0$. We have thereby obtained the full covariance matrix $\mathbb{D}$. Applying the original rotation gives the original covariance matrix as $\mathbb{Q'DQ}$.

You have supplied what your inputs are, the cone and the spheric covariance, but not what your output is.

Im going to guess that you want to see how far your cone is from being a unit-sphere.

You make a uniform random distribution that is truly spherical and compute its covariance, then you compare that with the covariance of your cone computed through the same method.

Notes:

• when computing your reference covariance from sample data, please feel free to make a good number of unique runs so that your data is truly characteristic.
• use the many runs to characterize your uncertainty. If you don't have enough samples then you should be aware of that.

Best of luck.

• Rather than changing the question and answering something that has not been asked, please consider consulting with the OP by means of comments requesting clarification. Sometimes your guess about the intention will be correct, but more often it will not be, and then posting an answer is both confusing and a potential waste of your time.
– whuber
May 6 '13 at 17:16
• What I'm looking for is a way to express the covariance matrix in terms of the parameters of my distribution (which is uniform on a subset of the uniform sphere). I would prefer not doing this numerically if it's not necessary. May 6 '13 at 17:28