#include <ExecStreamGenerator.h>
Inheritance diagram for PoissonColumnGenerator< T >:
Public Member Functions | |
PoissonColumnGenerator (T startValue, double meanDistance, int batchSize, uint seed) | |
virtual | ~PoissonColumnGenerator () |
T | next () |
Private Member Functions | |
void | generateBatch () |
Populates the next batch of values. | |
Private Attributes | |
T | currentValue |
vector< T > | nextValues |
batch of pre-generated values | |
int | ordinalInBatch |
position in the batch of the last value we returned | |
T | batchUpper |
upper bound of current batch, will be the lower bound of the next | |
std::subtractive_rng | rng |
double | meanDistance |
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.
Definition at line 189 of file ExecStreamGenerator.h.
PoissonColumnGenerator< T >::PoissonColumnGenerator | ( | T | 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 }
virtual PoissonColumnGenerator< T >::~PoissonColumnGenerator | ( | ) | [inline, virtual] |
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 }
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 }
T PoissonColumnGenerator< T >::currentValue [private] |
Definition at line 191 of file ExecStreamGenerator.h.
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().
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().
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().
std::subtractive_rng PoissonColumnGenerator< T >::rng [private] |
Definition at line 198 of file ExecStreamGenerator.h.
Referenced by PoissonColumnGenerator< T >::generateBatch().
double PoissonColumnGenerator< T >::meanDistance [private] |
Definition at line 199 of file ExecStreamGenerator.h.
Referenced by PoissonColumnGenerator< T >::generateBatch().