sample_powerlaw#
- gammapy.utils.random.sample_powerlaw(x_min, x_max, gamma, size=None, random_state='random-seed')[source]#
Sample random values from a power law distribution.
f(x) = x ** (-gamma) in the range x_min to x_max
It is assumed that gamma is the differential spectral index.
Reference: http://mathworld.wolfram.com/RandomNumber.html
- Parameters
- x_minfloat
x range minimum
- x_maxfloat
x range maximum
- gammafloat
Power law index
- sizeint, optional
Number of samples to generate
- random_state{int, ‘random-seed’, ‘global-rng’,
RandomState
} Defines random number generator initialisation. Passed to
get_random_state
.
- Returns
- xarray
Array of samples from the distribution