# Density of points uniformly distributed in a sphere

Suppose we have a set of points in $R^3$ distributed uniformly in a sphere.

Suppose we cut up the sphere in spherical shells of uniform thickness $\Delta r=r_n-r_{n-1}$. I want to find the density of points in each spherical shell.

Since outer shells are larger than inner shells, a proper measure of density would have to be somehow normalized. The straightforward answer would be to divide the number of points in each spherical shell by its volume, $\frac{4}{3}\pi (r_n^3 - r_{n-1}^3)$ and that would give a normalized density.

Here's some plots. X-axis: radial distance from center of sphere. Y-axis: number of points in corresponding spherical shell

This is density before normalizing for volume:

This is density after normalizing for volume:

Perhaps, refining this process will give a straight line for the normalized density and indeed this is the correct way of measuring what I want. However, taking alot more points and cutting up the sphere in much finer partitions, the results don't get drastically better. Perhaps it's an instance of slow convergence. But perhaps this method really has trouble as you approach the origin. Any ideas? I have no stat background, is this the way to go normalizing this set of points, are there other ways I'm not aware of that might deal better with points closer to the center of the sphere? Thanks

• Thanks for an interesting problem with careful illustration of what you're asking about. Dec 23, 2016 at 19:09

I don't quite get why you are ploting graphs (from simulations, I guess). The problem is quite simple. If the points are "distributed uniformly in a sphere", then the "normalized density" (average amount of points divided by volume) must be uniform. If the volume is not normalized, then, the density is proportional to the volume. For spherical shells, the volume is

$$v = \frac{4}{3} \pi ((r+\Delta r)^3 - r^3)= 4 \pi \Delta r(r^2 + r \Delta r + \frac{1}{3}\Delta r^2) \approx 4 \pi \Delta r\, r^2$$

where the approximation is valid for $\Delta r \to 0$

In a random experiment where we throw $N$ points uniformly inside the sphere (volume $V=\frac43 \pi R^3$), the (random) number of points inside some region with volume $v$ will follow a Binomial distribution with $p=v/V$, expected value $Np$ and variance $N p (1-p)$. The normalized density will have variance $$\frac{N (1-v/V)}{v V}$$ which says that, for small $v$, the variance grows, and hence the estimation will be more "noisy". Of course, this correspons to the fact that a in a small volume we'll get few points.

• Second point about 'noise' added while I was giving a binomial example of the same idea. (+1). Dec 23, 2016 at 19:04

The reason that the points closer to zero radius seem to have a high standard deviation is because those shells have smaller volumes, and therefore fewer points within those volumes.

The large standard deviation for those points is just due to smaller sample sizes when calculating the densities. You'll get a better curve (line) if your ratio of points to shell width is larger.

• Right. The point I was typing out at greater length while you posted this. (+1) Dec 23, 2016 at 19:00

Let's work on terminology a bit. Density ought to be points per unit volume (I guess what you mean by normalized.) A count of points ought to be called frequency.

Your second graph is 'fuzzier' at the left because you have lower frequency and hence greater variability. As a trivial, but relevant, analogy consider rolling dice. Let $X$ be the number of 6's in 60 rolls. Then $E(X) = 60(1/6) = 10,$ $V(X) = 60(1/6)(5/6) = 8.33$ and $SD(X) = 2.89,$ But the average number of 6's per roll is $A = X/60$ with $E(A) = 1/6$ and $SD(A) = 0.048.$

Now if you have 600 rolls $E(X) = 100,\, SD(X) = 9.13.$ And $E(A) = 1/6,\, SD(A) = 0.015.$ So as counts increase $SD(X)$ increases (as you can see at the right of your first plot), and $SD(A)$ decreases (right of the second).

Note: The Law of Large Numbers says points on your second graph will cluster ever more closely to a constant with increasing $n$.