GClasses
GClasses::GCategoricalSamplerBatch Class Reference

#include <GDistribution.h>

Public Member Functions

 GCategoricalSamplerBatch (size_t categories, const GVec &distribution, GRand &rand)
 categories specifies the number of categories. distribution should specify a probability value for each category. They should sum to 1. pDistribution is expected to remain valid for the duration of this object. More...
 
 ~GCategoricalSamplerBatch ()
 
void draw (size_t samples, size_t *pOutBatch)
 This will draw a batch of samples from the categorical distribution. This method is implemented efficiently, such that it will draw them in O(samples + categories) time. (This is significantly faster than O(samples * log(categories)) time, which is what you get if you use GCategoricalSampler.) More...
 

Static Public Member Functions

static void test ()
 

Protected Attributes

size_t m_categories
 
const GVecm_distribution
 
GRandomIndexIterator m_ii
 

Constructor & Destructor Documentation

GClasses::GCategoricalSamplerBatch::GCategoricalSamplerBatch ( size_t  categories,
const GVec distribution,
GRand rand 
)

categories specifies the number of categories. distribution should specify a probability value for each category. They should sum to 1. pDistribution is expected to remain valid for the duration of this object.

GClasses::GCategoricalSamplerBatch::~GCategoricalSamplerBatch ( )

Member Function Documentation

void GClasses::GCategoricalSamplerBatch::draw ( size_t  samples,
size_t *  pOutBatch 
)

This will draw a batch of samples from the categorical distribution. This method is implemented efficiently, such that it will draw them in O(samples + categories) time. (This is significantly faster than O(samples * log(categories)) time, which is what you get if you use GCategoricalSampler.)

static void GClasses::GCategoricalSamplerBatch::test ( )
static

Member Data Documentation

size_t GClasses::GCategoricalSamplerBatch::m_categories
protected
const GVec& GClasses::GCategoricalSamplerBatch::m_distribution
protected
GRandomIndexIterator GClasses::GCategoricalSamplerBatch::m_ii
protected