1

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.

  • 2
    Perhaps related to [dispersing-n-points-uniformly-on-a-sphere](https://stackoverflow.com/questions/14805583/dispersing-n-points-uniformly-on-a-sphere) ? – John Anderson Jan 27 '19 at 19:39
  • Consider also [Sampling uniformly distributed random points inside a spherical volume](https://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume) – hpaulj Jan 27 '19 at 20:50
  • Per John Anderson: possible duplicate of [Dispersing n points uniformly on a sphere](https://stackoverflow.com/questions/14805583/dispersing-n-points-uniformly-on-a-sphere) – Davis Herring Jan 28 '19 at 05:39
  • 1
    Consider the area between the circles of theta=1 degree and 2 degrees (near the pole), and that between 89 and 90 (on the equator). Uniformity in theta implies that each receives the same number of points. – Davis Herring Jan 28 '19 at 05:42
  • I think you may have an indentetion error in the last `else`, i.e. you should remove one indentation for `hs_point[j] = coord` so it stands outside the `if` block – Tarifazo Jan 28 '19 at 13:37

0 Answers0