0

I have a question i ve been thinking about for a few days:

I want to better understand the statistics of random 3 dimensional unit vectors. For example, i pick two angles $\theta$ and $\phi$ from $U(0,\pi)$ and $U(0,2\pi)$ respectively, i create the random vector $\mathbf {X} = \{\sin \theta \cos \phi, \sin \theta \sin \phi, \cos \theta\}$, repeat this $N$-times, and then i try to obtain the standard deviation over all $N$s of the components of $\mathbf{X}$. The mean is zero (the distribution is symmetric), so the standard deviation is:

$\sigma_i =\sqrt{\frac{1}{N-1} \sum^N X_i^2} \quad (1)$

for the component $i$. This is also how Matlab computes it. Now because of the spherical symmetry, the standard deviations ($N$ large) for all three components should be equal, i.e. $\sigma_1 = \sigma_2 = \sigma_3 = \sqrt{\frac{1}{3}}$, which i can prove with

$\sigma_i^2 = \frac{1}{4 \pi} \int_0^{\pi} \int_0^{2 \pi} X_i^2 \sin \theta d\theta d\phi \quad (2)$.

So equation (1) is wrong, because it misses the $\sin \theta$ weight. If this is implemented, then i obtain the correct result.

My question is now: If i don't know from which distribution i randomly pick the components, but still assume that it is symmetric around $0$ and that $\mathbf{X}$ is a unit vector, will $\sigma_i$ always be $\sqrt{\frac{1}{3}}$? And is there a way to obtain the weight just from equation (1) and the $X_i$'s?

Any help is appreciated !

EDIT: I will try to clarify: maybe i am mixing up the standard deviation (as used in the R program) with the second moment of the underlying distribution of the $X_i$'s. I want to find the latter. Here is my mathematica code:

n = 10000;
th = Table[Pi*RandomReal[], {n}]; ph = Table[2*Pi*RandomReal[], {n}];
x = Sin[th]*Cos[ph]; y = Sin[th]*Sin[ph]; z = Cos[th];
wx = WeightedData[x, Sin[ArcCos[z]]];
wy = WeightedData[y, Sin[ArcCos[z]]];
wz = WeightedData[z, Sin[ArcCos[z]]];
{StandardDeviation[x], StandardDeviation[wx]}
{StandardDeviation[y], StandardDeviation[wy]}
{StandardDeviation[z], StandardDeviation[wz]}

{0.499561, 0.578086} -> unweighted gives 1/2, weighted gives Sqrt[1/3]
{0.500725, 0.579126} -> unweighted gives 1/2, weighted gives Sqrt[1/3]
{0.706939, 0.574878} -> unweighted gives Sqrt[1/2], weighted gives Sqrt[1/3]

sqrt(1/3) is what i expect. My question now regards the case of arbitrary underlying distributions of the $X_i$'s

  • 1
    It is not clear what you are trying to do. You start by defining two random variables $\theta$ and $\phi.$ From them you define $X_1, X_2, X_3.$ Do you expect the $X_i$'s to be mutually independent? (Pairwise indep, perhaps.) Do you expect them to have the same distributions? In an attempted simulation in R, I don't get $\sigma_1=\sigma_2=\sigma_3.$ Please explain your purpose and check your definitions. // It is possible that R doesn't handle trig functions as expected, but I wasn't surprised by the results. Showing my simulation of 10,000 pairs/triples below. – BruceET Mar 07 '18 at 23:34
  • 2
    http://mathworld.wolfram.com/SpherePointPicking.html (if you want uniformity on the surface of the unit sphere) "it is incorrect to select spherical coordinates theta and phi from uniform distributions theta in [0,2pi) and phi in [0,pi], since the area element d(Omega)=sin phi d(theta) d(phi) is a function of phi, and hence points picked in this way will be "bunched" near the poles" – r.e.s. Mar 08 '18 at 00:02
  • yes exactly, thats why i need the weight, which is $\sin \theta$ in this case. How do i get the second moments of the underlying distributions if i dont know the weight? – M. Hennes Mar 08 '18 at 00:32
  • for example, what if $X_1 = \frac{1}{X} \sum_{i=1}^N \sin \theta_i \cos \phi_i$, $X_2 = \frac{1}{X} \sum_{i=1}^N \sin \theta_i \sin \phi_i$, and $X_3 = \frac{1}{X} \sum_{i=1}^N \cos \theta_i$, where the angles are all taken from $U(0,\pi)$ and $U(0,2 \pi)$ ? ($X$ is the norm of $\mathbf{X}$). I expect the weighted standard deviations to be $\sqrt{\frac{1}{3}}$ again, since no spatial direction is preferred, but can i find this weight? – M. Hennes Mar 08 '18 at 00:44
  • As i see it, incorporating the weight "debunches" the poles. that why i get $\sqrt{1/3}$ for all three second moments by means of equation (2). Which also makes sense, since my $\mathbf{X}$ is just the unit radial vector. Why should it fluctuate more in the third component, as BruceET got in his R-program? Fluctuations of a random unit radial vector should be equally shared among all three spatial components of this vector (hence $\sqrt{1/3}$). Especially since i can simply rotate the x,y,z frame and turn the one axis into another. – M. Hennes Mar 08 '18 at 01:06
  • Thanks @r.e.s for that link, where it is explicitly stated that the method in the Question is not correct--as I was hinting at in my Comments. I hope OP will revise the Question again, showing the correct approach. – BruceET Mar 08 '18 at 02:38

1 Answers1

1

You are making everything more complicated than it needs to be, and not quite correct.

A standard formula for standard deviation will give the desired result if the distribution is uniform. There are various ways to get a uniform distribution over a sphere. Choosing $\theta$ uniformly between $0$ and $\pi$ is not part of any of the ways I've ever seen. Several correct methods are described in the answers to How to generate random points on a sphere.

It's not really meaningful to use $X_i$ in the integral, because there's nothing random about the integral. You simply integrate over all possible vectors: $$\frac{1}{4\pi} \int_0^\pi \!\!\int_0^{2\pi} x_i^2 \sin\theta\, d\theta\, d\phi.$$ It seems to me to be misguided to think of this integral as weighting $x_i$ by $\sin\theta$; I would rather say that $\iint \cdots\sin\theta\,d\theta\,d\phi$ represents the integration of something (whatever you put in place of "$\cdots$") over the surface of the sphere. In other words, $\sin\theta\,d\theta\,d\phi$ is an expression for $dS$ where $S$ measures surface area.

So what you have done is, first, to construct a non-uniform distribution of points on the surface of the sphere; then, because you have packed too many points near the poles, you have to apply weights to those points so that they have only the same relative influence that the correct (smaller) number of points in that region would have had. In doing this, you make it impossible to simply use formulas that were meant to apply directly to distributions of random data, because the thing you're trying to measure is not represented by the distribution you generated. Rather than fix the underlying distribution so that it works as it should, you try to work around it by hacking the formulas.

The hacking also obscures the question of what happens with "other" distributions that $X_i$ might have. If we don't really intend the distribution to be different, but instead mean to "hack" it until it gives results like a uniform distribution over the area of the sphere, then of course we will always get the answer $\frac1{\sqrt3}.$ On the other hand, if we actually mean to investigate some other distribution of $X_i$ according to how that distribution actually behaves, then we can easily get results that are not $\frac1{\sqrt3},$ just as you got results that were not $\frac1{\sqrt3}$ when you measured the actual standard deviations of the coordinates of your actual distribution of random vectors.


For the uniform distribution, the result $\frac1{\sqrt3}$ is a conseuqence of the well-known fact that when points are uniformly distributed over a three-dimensional sphere, each coordinate of the points is uniformly distributed over the interval $[-1,1].$ See Projection of a uniform distribution on a sphere.

The standard deviation of a uniform distribution on an interval $[a,b]$ is $\frac1{\sqrt{12}}(b - a),$ and taking $a = -1$ and $b = 1$ this evaluates to $\frac1{\sqrt3}.$


By the way, the formula $$\sigma_i =\sqrt{\frac{1}{N-1} \sum^N (X_i - \bar X_i)^2} $$ is an estimator for the standard deviation when the true mean of the distribution is unknown. When we do not know the true mean, we use the estimated mean instead, but this tends to give a smaller result than you would get by using the true mean. We compensate by using $\frac1{1-N}$ instead of $\frac1N.$ (This is not a perfect solution of that problem, but that's beyond the level of this discussion.)

In your case, since you know the mean is $0$ and do not need to use $\bar X_i$ to estimate the mean, the formula for standard deviation would be $$\sigma_i =\sqrt{\frac{1}{N} \sum^N X_i^2}. $$ Of course for large values of $N$ you may not notice the difference between the results of the formulas.

David K
  • 98,388
  • Yes i agree, the formulation is unnecessarily complicated. It is easier to generate random points on the sphere which do not exhibit the "bunching" near the poles, and continue with corresponding radial unit vectors to construct whatever. Thx! i will accept the answer – M. Hennes Mar 08 '18 at 10:43