0

I have a list of spheres with some known characteristics (ids, radii, masses, and positions) with ids, radii, and masses being 1D arrays with shape (511, ) and positions being 3D array with shape (511, 3) inside some big spherical volume with known center, (0, 0, 0) and radius, distance_max.

hal_ids_data = np.array([19895, 19896, ..., 24249])                   
hal_radiuss_data = np.array([1.047, 1.078, ..., 3.263])                 
hal_masss_data = np.array([2.427e+06, 8.268e+06, ..., 8.954e+07]     
hal_positions_data = np.array([np.array([-33.78, 10.4, 33.83]), np.array([-33.61, 6.34, 35.64]), ..., np.array([-0.4014, 4.121, 33.05])])

I would like to randomly place these tiny spheres throughout the volume within the big sphere while keeping their individual characteristics intact meaning only their positions need to be shuffled subject to two constraints shown below.

for hal_id, hal_position, hal_radius, hal_mass in zip(hal_ids_data, hal_positions_data, hal_radiuss_data, hal_masss_data):

    # check if 1) any one of the small spheres are above some mass threshold AND 2) inside the big sphere
    if ((np.sqrt(pow(hal_position[0], 2)+pow(hal_position[1], 2)+pow(hal_position[2], 2)) < distance_max) and (log10(hal_mass)>=1e8)):

        # if so, then do the following stuff down here but to the shuffled populations of small spheres meeting the conditions above rather than to the original population

What is the fastest and shortest numerical algorithm to shuffle my small spheres under the last if statement before doing some stuff on them? (I do need my original population info though for later use so I cannot disregard it)

Ash
  • 131
  • 3
  • Do the little spheres need to be disjoint or can they overlap? – whuber Aug 09 '20 at 18:31
  • They can overlap. All I care is that their positions (centers) are distributed based on a uniform random distribution. – Ash Aug 09 '20 at 18:45
  • Aren you just asking, then, how to generate uniformly random locations within a given sphere? One (good) method is given in the *question* at https://stats.stackexchange.com/questions/85488. – whuber Aug 09 '20 at 18:49
  • Thank You, yes. this is what I want. Thank You, – Ash Aug 09 '20 at 20:28
  • See [here](https://stats.stackexchange.com/questions/481715/) for an ```R``` function that does this for you. – Ben Aug 09 '20 at 22:32
  • I am more interested in a 3D version of the problem where I can place my sphere in a uniformly distributed random position inside a bigger sphere. So, I think what whuber pointed out is the best option fo rme but I am trying to see why it still seems that we are biased by putting more points in the innermost region of the big sphere. – Ash Aug 10 '20 at 03:49
  • Thank You Ben, but I actually am not familiar much with R – Ash Aug 10 '20 at 03:50

0 Answers0