def randomly_sample_sphere(ntosample, randomseed=12345):
 with NumpyRNGContext(randomseed):
  lat = np.arcsin(((np.random.rand(ntosample) * 2) - 1))
  lon = ((np.random.rand(ntosample) * np.pi) * 2)
  r = np.random.rand(ntosample)
 return ((lon * u.rad), (lat * u.rad), r)

def randomly_sample_sphere ( ntosample , randomseed = 12345 ) : with NumpyRNGContext ( randomseed ) : lat = np . arcsin ( ( ( np . random . rand ( ntosample ) * 2 ) - 1 ) ) lon = ( ( np . random . rand ( ntosample ) * np . pi ) * 2 ) r = np . random . rand ( ntosample ) return ( ( lon * u . rad ) , ( lat * u . rad ) , r )
generates a set of spherical coordinates uniformly distributed over the sphere in a way that gives the same answer for the same seed .