GClasses
|
This class is for efficiently drawing random values from a categorical distribution with a large number of categories. More...
#include <GDistribution.h>
Public Member Functions | |
GCategoricalSampler (size_t categories, const double *pDistribution) | |
categories specifies the number of categories. pDistribution should specify a probability value for each category. They should sum to 1. | |
~GCategoricalSampler () | |
size_t | draw (double d) |
d should be a random uniform value from 0 to 1. The corresponding zero-based category index is returned. This method will take log(categories) time. | |
Protected Attributes | |
std::map< double, size_t > | m_map |
This class is for efficiently drawing random values from a categorical distribution with a large number of categories.
GClasses::GCategoricalSampler::GCategoricalSampler | ( | size_t | categories, |
const double * | pDistribution | ||
) |
categories specifies the number of categories. pDistribution should specify a probability value for each category. They should sum to 1.
GClasses::GCategoricalSampler::~GCategoricalSampler | ( | ) | [inline] |
size_t GClasses::GCategoricalSampler::draw | ( | double | d | ) |
d should be a random uniform value from 0 to 1. The corresponding zero-based category index is returned. This method will take log(categories) time.
std::map<double,size_t> GClasses::GCategoricalSampler::m_map [protected] |