MPI distrib exp: added the normal Gaussian distribution
This commit is contained in:
parent
a3a04e0112
commit
7c3eee4ddd
1 changed files with 52 additions and 0 deletions
|
|
@ -97,6 +97,58 @@ class UniformDistribution : public Distribution
|
||||||
|
|
||||||
} uniformDistribution;
|
} uniformDistribution;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Normal (gaussian) distribution of times.
|
||||||
|
*
|
||||||
|
* A normal distribution is defined by a mean and a standard deviation.
|
||||||
|
*/
|
||||||
|
class NormalDistribution : public Distribution
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
NormalDistribution() : _rng( 0 )
|
||||||
|
{
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
~NormalDistribution()
|
||||||
|
{
|
||||||
|
if( _rng )
|
||||||
|
{
|
||||||
|
delete _rng;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void make_parser( eoParser & parser )
|
||||||
|
{
|
||||||
|
_active = parser.createParam( false, "normal", "Normal distribution", '\0', "Normal").value();
|
||||||
|
_mean = parser.createParam( 0.0, "normal-mean", "Mean for the normal distribution (0 by default), in ms.", '\0', "Normal").value();
|
||||||
|
double _stddev = parser.createParam( 1.0, "normal-stddev", "Standard deviation for the normal distribution (1ms by default), 0 isn't acceptable.", '\0', "Normal").value();
|
||||||
|
|
||||||
|
if( _active )
|
||||||
|
{
|
||||||
|
_rng = new eoNormalGenerator<double>( _stddev );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int next_element()
|
||||||
|
{
|
||||||
|
int next = std::floor( _mean + (*_rng)() );
|
||||||
|
if( next < 0 )
|
||||||
|
{
|
||||||
|
next = 0;
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
eoNormalGenerator<double> * _rng;
|
||||||
|
|
||||||
|
double _mean;
|
||||||
|
|
||||||
|
} normalDistribution;
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
Node::init( argc, argv );
|
Node::init( argc, argv );
|
||||||
|
|
|
||||||
Reference in a new issue