Let the Cartesian x,y coordinates of a random point be selected s.t. (x,y)∼U(−10,10)×U(−10,10).

Thus, the radius, ρ=√x2+y2, isn’t uniformly distributed as implied by ρ‘s p.d.f.

Nonetheless I would expect θ=arctanyx to be almost uniform, excluding artifacts due to the 4 leftovers at the edges:

Following are the grafically calculated probability density functions of θ and ρ:

Now if I let x,y be distributed s.t. x,y∼N(0,202)×N(0,202) then θ seems uniformly distributed:

Why θ isn’t uniform when (x,y)∼U(−10,10)×U(−10,10) and is uniform when x,y∼N(0,202)×N(0,202)?

The Matlab code I used:

`number_of_points = 100000; rng('shuffle') a = -10; b = 10; r = (b-a).*randn(2,number_of_points); r = reshape(r, [2,number_of_points]); I = eye(2); e1 = I(:,1); e2 = I(:,2); theta = inf*ones(1,number_of_points); rho = inf*ones(1,number_of_points); for i=1:length(r(1,:)) x = r(:,i); [theta(i),rho(i)] = cart2pol(x(1),x(2)); end figure M=3;N=1; bins = 360; subplot(M,N,1); histogram(rad2deg(theta), bins) title('Polar angle coordinate p.d.f'); subplot(M,N,2); histogram(rho, bins); title('Polar radius coordinate p.d.f'); subplot(M,N,3); histogram(r(:)); title('The x-y cooridnates distrbution (p.d.f)');`

Substituting the 3rd line:

`r = (b-a).*randn(2,number_of_points);`

with`r = (b-a).*randn(2,number_of_points) +a ;`

will change the distribution of (x,y) from normal to uniform.

**Answer**

You’re referring to a transformation from a pair of independent variates (X,Y) to the polar representation (R,θ) (radius and angle), and then looking at the marginal distribution of θ.

I’m going to offer a somewhat intuitive explanation (though a mathematical derivation of the density does essentially what I describe informally).

Note that if you scale the two variables, X and Y by some common scale (e.g. go from U(-1,1) to U(-10,10) or from N(0,1) to N(0,20) on both variables at the same time) that makes no difference to the distribution of the angle (it only affects the scale of the distribution of the radius). So let’s just consider the unit cases.

First consider what’s going on with the uniform case. Note that the distribution is uniform over the unit square, so that the probability density in a region that’s contained within [−1,1]2 is proportional to the area of the region. Specifically, look at the density associated with an element of angle, dθ near the horizontal (near angle θ=0) and on the diagonal (near angle θ=π/4):

Clearly the probability element dfθ (i.e. area) corresponding to an element of angle (dθ) is larger when the angle is near one of the diagonals. Indeed consider inscribing a circle inside the square; the area spanned by a given tiny angle within the circle is constant, and then the part outside the circle grows as we approach the diagonal, where it at its maximum.

This completely accounts for the pattern you see in the simulations.

Indeed, we can see that the density must be proportional to the length of the segment from the center of the square to its edge; simple trigonometry is sufficient to derive the density from there and then it’s easy to find the constant required to make the density integrate to 1.

[Edit: added this next bit to discuss the radius, since the question has changed since my original answer.]

Note that if we had a uniform distribution over the unit circle (i.e. the one we inscribed in the square before) then the density of the radius for that would be proportional to the radius (consider the area of a small annular element of width dr at radius r – i.e. between r and r+dr – has area proportional to r). Then as we pass outside the circle, new annular regions with larger radius only get density contributions from the part in the square, so the density decreases (initially quite rapidly, then more slowly) between 1 and √2. (Again, fairly simple geometrical notions are sufficient to get the functional form of the density if it is needed.)

By contrast, if the joint distribution is rotationally symmetric about the origin then the probability element at some angle doesn’t depend on the angle (this is essentially a tautology!). The bivariate distribution of two independent standard Gaussians is rotationally symmetric about the origin:

(code for this image based on Elan Cohen’s code here but there’s a nice alternative here, and something between the two here)

Consequently the volume contained in some angle dθ is the same for every θ, so the density associated with the angle is uniform on [0,2π).

[The polar trick typically used for integrating the normal density over the real line can be used to figure out that the density of the squared radius is negative exponential, and from there the density of the radius is simple to identify by a simple transformation argument from the distribution function]

**Attribution***Source : Link , Question Author : 0x90 , Answer Author : Glen_b*