I have written code that randomly generates a 3D vector of random magnitude. I now want to create a histogram of how many vectors lie in the concentric spherical shells (n*delta r, (n+1)delta r) starting from (0, delta r). The simplest way to do this is just find how many endpoints end up in each shell but I'm not sure how to go about this.
This can be achieved easily. Let's say you have 200 random vectors
The magnitude of a vector is just the length which can be calculated using
You can count like this:
and then if you have 100 vectors:
You can also make a histogram. Here, with bin widths 1:
and here with bin widths .1: