PoissonColumnGenerator< T > Class Template Reference

Column generator which generates values with a Poisson distribution. More...

#include <ExecStreamGenerator.h>

Inheritance diagram for PoissonColumnGenerator< T >:

ColumnGenerator< T > List of all members.

Public Member Functions

 PoissonColumnGenerator (T startValue, double meanDistance, int batchSize, uint seed)
virtual ~PoissonColumnGenerator ()
next ()

Private Member Functions

void generateBatch ()
 Populates the next batch of values.

Private Attributes

currentValue
vector< T > nextValues
 batch of pre-generated values
int ordinalInBatch
 position in the batch of the last value we returned
batchUpper
 upper bound of current batch, will be the lower bound of the next
std::subtractive_rng rng
double meanDistance

Detailed Description

template<class T = int64_t>
class PoissonColumnGenerator< T >

Column generator which generates values with a Poisson distribution.

The Poisson distribution is a statistical distribution which characterizes the intervals between successive events. For example, consider a large sample of a radioactive isotope with a long half-life, and a Geiger counter measuring decay events. The number of events N between time t=0 and t=1 will be Poisson distributed.

This generator generates an ascending sequence of values with a given mean distance between values. For example, the sequence [3, 17, 24, 39, 45] might be the first five values generated if startValue = 0 and meanDistance = 10.

The generator generates a better statistical distribution if you give it a larger value of batchSize.

Author:
Julian Hyde

Definition at line 189 of file ExecStreamGenerator.h.


Constructor & Destructor Documentation

template<class T = int64_t>
PoissonColumnGenerator< T >::PoissonColumnGenerator ( startValue,
double  meanDistance,
int  batchSize,
uint  seed 
) [inline, explicit]

Definition at line 202 of file ExecStreamGenerator.h.

References PoissonColumnGenerator< T >::batchUpper, PoissonColumnGenerator< T >::nextValues, and PoissonColumnGenerator< T >::ordinalInBatch.

00206                    : rng(seed)
00207     {
00208         assert(batchSize > 0);
00209         assert(meanDistance > 0);
00210         assert(meanDistance * batchSize >= 1);
00211         this->batchUpper = startValue;
00212         nextValues.resize(batchSize);
00213         this->ordinalInBatch = batchSize;
00214         this->meanDistance = meanDistance;
00215     }

template<class T = int64_t>
virtual PoissonColumnGenerator< T >::~PoissonColumnGenerator (  )  [inline, virtual]

Definition at line 217 of file ExecStreamGenerator.h.

00218         {}


Member Function Documentation

template<class T = int64_t>
T PoissonColumnGenerator< T >::next (  )  [inline, virtual]

Implements ColumnGenerator< T >.

Definition at line 220 of file ExecStreamGenerator.h.

References PoissonColumnGenerator< T >::generateBatch(), PoissonColumnGenerator< T >::nextValues, and PoissonColumnGenerator< T >::ordinalInBatch.

00221     {
00222         if (ordinalInBatch >= nextValues.size()) {
00223             generateBatch();
00224         }
00225         return nextValues[ordinalInBatch++];
00226     }

template<class T = int64_t>
void PoissonColumnGenerator< T >::generateBatch (  )  [inline, private]

Populates the next batch of values.

Definition at line 230 of file ExecStreamGenerator.h.

References PoissonColumnGenerator< T >::batchUpper, PoissonColumnGenerator< T >::meanDistance, PoissonColumnGenerator< T >::nextValues, PoissonColumnGenerator< T >::ordinalInBatch, and PoissonColumnGenerator< T >::rng.

Referenced by PoissonColumnGenerator< T >::next().

00230                          {
00231         // The next batch will contain nextValues.size() values with a mean
00232         // inter-value distance of meanDistance, hence its values will range
00233         // from batchLower to batchLower + nextValues.size() * meanDistance.
00234         T batchLower = this->batchUpper;
00235         int batchRange = (int) (meanDistance * nextValues.size());
00236         T batchUpper = batchLower + batchRange;
00237         assert(batchUpper > batchLower);
00238         for (int i = 0; i < nextValues.size(); i++) {
00239             nextValues[i] = batchLower + static_cast<T>(rng(batchRange));
00240         }
00241         std::sort(nextValues.begin(), nextValues.end());
00242         this->batchUpper = batchUpper;
00243         this->ordinalInBatch = 0;
00244     }


Member Data Documentation

template<class T = int64_t>
T PoissonColumnGenerator< T >::currentValue [private]

Definition at line 191 of file ExecStreamGenerator.h.

template<class T = int64_t>
vector<T> PoissonColumnGenerator< T >::nextValues [private]

batch of pre-generated values

Definition at line 193 of file ExecStreamGenerator.h.

Referenced by PoissonColumnGenerator< T >::generateBatch(), PoissonColumnGenerator< T >::next(), and PoissonColumnGenerator< T >::PoissonColumnGenerator().

template<class T = int64_t>
int PoissonColumnGenerator< T >::ordinalInBatch [private]

position in the batch of the last value we returned

Definition at line 195 of file ExecStreamGenerator.h.

Referenced by PoissonColumnGenerator< T >::generateBatch(), PoissonColumnGenerator< T >::next(), and PoissonColumnGenerator< T >::PoissonColumnGenerator().

template<class T = int64_t>
T PoissonColumnGenerator< T >::batchUpper [private]

upper bound of current batch, will be the lower bound of the next

Definition at line 197 of file ExecStreamGenerator.h.

Referenced by PoissonColumnGenerator< T >::generateBatch(), and PoissonColumnGenerator< T >::PoissonColumnGenerator().

template<class T = int64_t>
std::subtractive_rng PoissonColumnGenerator< T >::rng [private]

Definition at line 198 of file ExecStreamGenerator.h.

Referenced by PoissonColumnGenerator< T >::generateBatch().

template<class T = int64_t>
double PoissonColumnGenerator< T >::meanDistance [private]

Definition at line 199 of file ExecStreamGenerator.h.

Referenced by PoissonColumnGenerator< T >::generateBatch().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:40 2009 for Fennel by  doxygen 1.5.1