I'm setting up a data set, and the goal is to make a sphere with a normal distribution along the radial direction, and uniform theta and phi distributions. Despite using uniform distributions for theta and phi, I keep getting regions of very dense points at the poles (symmetrically near +/- radius on the z axis) that have a small but noticeable size. I am also writing to a file and using ROOT to plot my results.
I've tried reducing the range of theta and phi to graph half a sphere, but the problem still persists in both cases. I have also set the radius to a constant to make sure that wasn't interfering with the formation of the poles. The poles still formed.
#Size is the number of points to generate, and n is the dimension of the problem (n=2 for circle, n=3 for sphere, etc.)
hs_points = np.zeros((size, n))
for i in range(size):
hs_point = hs_points[i]
for j in range(n):
if j == 0:
# normal distribution on radius
coord = np.random.normal(mu, sigma)
elif j < n-1:
coord=round(random.uniform(0,np.pi),15)
else:
coord = np.random.rand()*(2*np.pi)
hs_point[j] = coord
hs_points[i] = hs_point
return hs_points
c_points = np.zeros((size, n))
# translate each hyperspherical point into a cartesian point
for i in range(size):
hs_point = hs_points[i]
xCoord=hs_point[0]*np.sin(hs_point[1])*np.cos(hs_point[2])
yCoord=hs_point[0]*np.sin(hs_point[1])*np.sin(hs_point[2])
zCoord=hs_point[0]*np.cos(hs_point[1])
c_points[i,0]=xCoord
c_points[i,1]=yCoord
c_points[i,2]=zCoord
I expect the program to output a "fuzzy" sphere with a normal distribution along the radial direction, but with uniform behavior everywhere else (i.e. no particularly dense regions). Actual behavior is the generation of dense poles with uniform behavior everywhere else.