sample_sphere_distance

gammapy.utils.random.sample_sphere_distance(distance_min=0, distance_max=1, size=None, random_state='random-seed')[source]

Sample random distances if the 3-dim space density is constant.

This function uses inverse transform sampling (Wikipedia) to generate random distances for an observer located in a 3-dim space with constant source density in the range (distance_min, distance_max).

Parameters
distance_min, distance_maxfloat, optional

Distance range in which to sample

sizeint or tuple of ints, optional

Output shape. Default: one sample. Passed to numpy.random.uniform.

random_state{int, ‘random-seed’, ‘global-rng’, RandomState}

Defines random number generator initialisation. Passed to get_random_state.

Returns
distancearray

Array of samples