MPI Distrib exp: added exponential distribution
This commit is contained in:
parent
b4650e040c
commit
211ac8141e
1 changed files with 28 additions and 0 deletions
|
|
@ -130,6 +130,33 @@ class NormalDistribution : public Distribution
|
||||||
double _stddev;
|
double _stddev;
|
||||||
} normalDistribution;
|
} normalDistribution;
|
||||||
|
|
||||||
|
class ExponentialDistribution : public Distribution
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
ExponentialDistribution() : _rng( 0 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
void make_parser( eoParser & parser )
|
||||||
|
{
|
||||||
|
_active = parser.createParam( false, "exponential", "Exponential distribution", '\0', "Exponential").value();
|
||||||
|
_mean = parser.createParam( 0.0, "exponential-mean", "Mean for the exponential distribution (0 by default), in ms.", '\0', "Exponential").value();
|
||||||
|
}
|
||||||
|
|
||||||
|
int next_element()
|
||||||
|
{
|
||||||
|
return std::floor( _rng.negexp( _mean ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
eoRng _rng;
|
||||||
|
double _mean;
|
||||||
|
|
||||||
|
} exponentialDistribution;
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
Node::init( argc, argv );
|
Node::init( argc, argv );
|
||||||
|
|
@ -142,6 +169,7 @@ int main( int argc, char** argv )
|
||||||
std::vector<Distribution*> distribs;
|
std::vector<Distribution*> distribs;
|
||||||
distribs.push_back( &uniformDistribution );
|
distribs.push_back( &uniformDistribution );
|
||||||
distribs.push_back( &normalDistribution );
|
distribs.push_back( &normalDistribution );
|
||||||
|
distribs.push_back( &exponentialDistribution );
|
||||||
|
|
||||||
// for each available distribution, check if activated.
|
// for each available distribution, check if activated.
|
||||||
// If no distribution is activated, show an error message
|
// If no distribution is activated, show an error message
|
||||||
|
|
|
||||||
Reference in a new issue