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
Minimum x range.
- x_maxfloat
Maximum x range.
- gammafloat
Power law index.
- sizeint, optional
Number of samples to generate. Default is None.
- random_state{int, ‘random-seed’, ‘global-rng’,
RandomState
}, optional Defines random number generator initialisation. Passed to
get_random_state
. Default is “random-seed”.
- Returns:
- x
ndarray
Array of samples from the distribution.
- x