PDF of angle between normally distributed position vector and fixed unit vector in 2D vs 3D-space

309 Views Asked by At

I'm not a mathematician. But I came across a math-related question while trying to prove something in Python. So I hope that I'm fine posting over here.

I get a different distribution for the 2D & the 3D-case when I look at the angles between a vector that is normally distributed around another vector and I don't know if that is supposed to happen or not or I did do something wrong here.

I can explain the 2D case to me but not the 3D case

2D Case:

First I look at 2D Space in cartesian x, y-coordinates with a unit-vector $\vec{x}=\array(1,0)$

Now I want $n$ vectors that are normally distributed around $\vec{x}$.

In Python I do this with:

$n=10000$

$vX=np.random.normal(1, 0.02, size=n)$

$vY=np.random.normal(0, 0.02, size=n)$

$\vec{v}=(vX, vY)$

So if I now with the help of the dot-product look at all the angles between x and v I get a distribution that looks like this:

$\phi=\arccos\left(\frac{\vec{x}\cdot\vec{v}}{|\vec{x}|\cdot|\vec{v}|}\right)$

https://i.stack.imgur.com/su1o5.jpg

Which is totally what I expect since the randomly distributed vector $\vec{v}$ is centered around $\vec{x}$ and thus the most probable angle is $0°$.

3D Case:

If I switch to the 3D case now I just add 1 dimension to the vectors with the unit-vector being $\vec{x}=\array(1,0,0)$ and the normally distributed vector being

$vX=np.random.normal(1, 0.02, size=n)$

$vY=np.random.normal(0, 0.02, size=n)$

$vZ=np.random.normal(0, 0.02, size=n)$

$\vec{v}=(vX, vY, vZ)$

Then I calculate the angle between the random vectors $\vec{v}$ and $\vec{x}$ again and get the following distribution.

https://i.stack.imgur.com/2W68X.jpg

I can't imagine now why the most probable angle is not $0°$ anymore and this doesn't make sense to me since the vector $\vec{v}$ (in my imagination) is still centered around $\vec{x}$.

I don't want a hard mathematical proof here in case my result is true but in this case would be very pleased if it can be explained in layman-terms.

I hope that my question is clear.

Thanks a lot in advance.

2

There are 2 best solutions below

1
On BEST ANSWER

Without going into details, this is expected.

Details lite: If your random point is $x=(x_1, x_2,\ldots,x_n)$ and your fixed vector is $c=(1,0,\ldots,0)$ (and it might as well be), the angle is determined by the square of its cosine, $\cos^2 \theta = (x,c)^2/\|x\|^2$ which is $x_1^2/(x_1^2 + x_2^2 + \ldots x_n^2)$. The term $x_1^2$ gets washed out by the others more and more as $n$ gets bigger. As you move from $n=2$ to $3$, and so on.

0
On

The problem you encounter here is a common source of confusion when people are dealing with probabilities. Although this is in principle not difficult, it is very easy to make mistakes, and one needs to be very careful to ensure that such results and observations are interpreted in the correct fashion.

Since you use a normal distribution, points can be in principle everywhere in the plane, but with a standard deviation of 0.02, only 1 in every 64000 points and 1 in every 270000 points would be found outside a circle respectively sphere with radius 0.1 around the designated point. So we can safely assume, that we only have to consider points within such a small circle/sphere.

Now imagine that in the 2D case we draw from the origin lines in the direction of that circle, in such a way that the angels $\theta$ between neighbouring lines are constant and very small. They will slice up the circle where the generated points are found in very narrow trapezoids. The probability that we find a point that makes an angle $\phi$ with the $x$-axis is than proportional to the area of intersection (one of the trapezoids), and since for larger angles the height of the trapezoids decreases and their width is approximately the same, this means that it is more likely to find a smaller angle than a large angle. (For simplicity I used a homogenous probability rather than a normal distribution, but that mainly affects some of the finer details.)

You could do the same in the 3D case. But now rather than lines you would have cones radiating from the origin and they would intersect with a sphere. In this case the probability to lie between two surfaces of truncated cones would be proportional to the volume between them. The first cone however is very narrow with a small circular base, whereas the second cone has a bigger base with double the radius and four times the area. Therefor the probability to be in the second cone is 4 times as large as for being in the first one. Of course, we actually need to consider the volume between the first and second surface, but that is still three times as large. As a consequence, the probability to find a certain angle would increase for small angles, but starts decreasing again once the angles get bigger and the effect of the diminishing height of the truncated cones becomes noticeable.

Concerning, your later question shooting on a target we have a different situation and the subtle thing we need to distinguish is that there are different types of probabilities involved. Since we would have something like a normal distribution the most likely position to be found is indeed the centre (assuming our aim is good). What this actually says is, that if we would draw a fine square grid on the target, that the probability to hit a particular small square is larger when we are closer to the centre of the target. If we think about the angle, however, we need to realise that that an angle does not correspond to a single small square, but to one of the circular rings around the bulls eye. So the probability of finding a certain angle scales with the area of a ring, which just as in the case of the 3D sphere gives a probability (for finding a particular angle) that has a maximum that is not found at the zero-angle or bulls-eye, but away from that.