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).

distance_minfloat, optional

Minimum distance. Default is 0.

distance_maxfloat, optional

Maximum distance. Default is 1.

sizeint or tuple of ints, optional

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

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

Defines random number generator initialisation. Passed to get_random_state. Default is “random-seed”.


Array of samples.