InverseCDFSampler

class gammapy.utils.random.InverseCDFSampler(pdf, axis=None, random_state=0)[source]

Bases: object

Inverse CDF sampler.

It determines a set of random numbers and calculate the cumulative distribution function.

Parameters:
pdf : Map

Map of the predicted source counts.

axis : int

Axis along which sampling the indexes.

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

Defines random number generator initialisation. Passed to get_random_state.

Methods Summary

sample(self, size) Draw sample from the given PDF.
sample_axis(self) Sample along a given axis.

Methods Documentation

sample(self, size)[source]

Draw sample from the given PDF.

Parameters:
size : int

Number of samples to draw.

Returns:
index : tuple of ndarray

Coordinates of the drawn sample.

sample_axis(self)[source]

Sample along a given axis.

Returns:
index : tuple of ndarray

Coordinates of the drawn sample.