0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hypertable::DiscreteRandomGenerator Class Reference

Generates samples from a discrete probability distribution in the range [0, max_val] by transforming a uniform [0, 1] distribution into the desired distribution. More...

#include <DiscreteRandomGenerator.h>

Inheritance diagram for Hypertable::DiscreteRandomGenerator:
Inheritance graph
[legend]

Public Member Functions

 DiscreteRandomGenerator ()
 Default constructor; sets up a random number generator with a constant seed value of 1. More...
 
virtual ~DiscreteRandomGenerator ()
 Destructor - cleans up allocated resources. More...
 
void set_seed (uint32_t s)
 Sets the seed for the random number generator. More...
 
void set_value_count (uint64_t value_count)
 Sets the size of the generated range. More...
 
void set_pool_min (uint64_t pool_min)
 Sets the lowest value of the desired distribution. More...
 
void set_pool_max (uint64_t pool_max)
 Sets the highest value of the desired distribution. More...
 
virtual uint64_t get_sample ()
 Returns a random sample from the distribution. More...
 

Protected Member Functions

virtual void generate_cmf ()
 Generate the cumulative mass function for the distribution. More...
 
virtual double pmf (uint64_t val)
 Returns the probability of drawing a specific value from the distribution. More...
 

Protected Attributes

std::mt19937 m_random_engine {1}
 The random number generator. More...
 
uint64_t m_value_count {}
 Number of values in the range. More...
 
uint64_t m_pool_min {}
 Lower bound of the range. More...
 
uint64_t m_pool_max {}
 Upper bound of the range. More...
 
uint64_t * m_numbers {}
 Array with the random samples. More...
 
double * m_cmf {}
 The cumulative mass of the distribution. More...
 

Detailed Description

Generates samples from a discrete probability distribution in the range [0, max_val] by transforming a uniform [0, 1] distribution into the desired distribution.

Definition at line 45 of file DiscreteRandomGenerator.h.

Constructor & Destructor Documentation

Hypertable::DiscreteRandomGenerator::DiscreteRandomGenerator ( )
inline

Default constructor; sets up a random number generator with a constant seed value of 1.

Definition at line 50 of file DiscreteRandomGenerator.h.

virtual Hypertable::DiscreteRandomGenerator::~DiscreteRandomGenerator ( )
inlinevirtual

Destructor - cleans up allocated resources.

Definition at line 53 of file DiscreteRandomGenerator.h.

Member Function Documentation

void DiscreteRandomGenerator::generate_cmf ( )
protectedvirtual

Generate the cumulative mass function for the distribution.

Definition at line 79 of file DiscreteRandomGenerator.cc.

uint64_t DiscreteRandomGenerator::get_sample ( )
virtual

Returns a random sample from the distribution.

Reimplemented in Hypertable::DiscreteRandomGeneratorUniform.

Definition at line 34 of file DiscreteRandomGenerator.cc.

virtual double Hypertable::DiscreteRandomGenerator::pmf ( uint64_t  val)
inlineprotectedvirtual

Returns the probability of drawing a specific value from the distribution.

Parameters
valvalue to be generated
Returns
probability of generating this value

Reimplemented in Hypertable::DiscreteRandomGeneratorZipf.

Definition at line 113 of file DiscreteRandomGenerator.h.

void Hypertable::DiscreteRandomGenerator::set_pool_max ( uint64_t  pool_max)
inline

Sets the highest value of the desired distribution.

Parameters
pool_maxThe upper bound of the range

Definition at line 91 of file DiscreteRandomGenerator.h.

void Hypertable::DiscreteRandomGenerator::set_pool_min ( uint64_t  pool_min)
inline

Sets the lowest value of the desired distribution.

Parameters
pool_minThe lower bound of the range

Definition at line 79 of file DiscreteRandomGenerator.h.

void Hypertable::DiscreteRandomGenerator::set_seed ( uint32_t  s)
inline

Sets the seed for the random number generator.

Parameters
sThe seed value for the random number generator

Definition at line 59 of file DiscreteRandomGenerator.h.

void Hypertable::DiscreteRandomGenerator::set_value_count ( uint64_t  value_count)
inline

Sets the size of the generated range.

Parameters
value_countThe number of values in the range

Definition at line 67 of file DiscreteRandomGenerator.h.

Member Data Documentation

double* Hypertable::DiscreteRandomGenerator::m_cmf {}
protected

The cumulative mass of the distribution.

Definition at line 131 of file DiscreteRandomGenerator.h.

uint64_t* Hypertable::DiscreteRandomGenerator::m_numbers {}
protected

Array with the random samples.

Definition at line 128 of file DiscreteRandomGenerator.h.

uint64_t Hypertable::DiscreteRandomGenerator::m_pool_max {}
protected

Upper bound of the range.

Definition at line 125 of file DiscreteRandomGenerator.h.

uint64_t Hypertable::DiscreteRandomGenerator::m_pool_min {}
protected

Lower bound of the range.

Definition at line 122 of file DiscreteRandomGenerator.h.

std::mt19937 Hypertable::DiscreteRandomGenerator::m_random_engine {1}
protected

The random number generator.

Definition at line 116 of file DiscreteRandomGenerator.h.

uint64_t Hypertable::DiscreteRandomGenerator::m_value_count {}
protected

Number of values in the range.

Definition at line 119 of file DiscreteRandomGenerator.h.


The documentation for this class was generated from the following files: