GeneralRandomArray

class gammapy.utils.distributions.GeneralRandomArray(pdf)[source]

Bases: object

Draw random indices from a discrete probability distribution given by a numpy array. The array dimension can be arbitrary.

Note that drawing a random number from an array with N entries is not a constant cost operation. Even the efficient implementation using a binary tree used here costs log(N).

For a general description of the method see the end of the following page: http://www.cs.utk.edu/~parker/Courses/CS302-Fall06/Notes/PQueues/random_num_gen.html

Methods Summary

draw(self[, n, return_flat_index, random_state]) Returns n draws from the pdf.

Methods Documentation

draw(self, n=1, return_flat_index=False, random_state='random-seed')[source]

Returns n draws from the pdf.

If return_flat_index == true, a linearized index is returned.

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

Defines random number generator initialisation. Passed to get_random_state.