last update 20 Sep 2009 |
#include <cvrUniformDiscreteDistribution.h>
This class generates (pseudo) random numbers uniformly distributed in an interval specified in the parameters.
In the sake of speed, the classical modulo operation is used to avoid multiplications and divisions. The error introduced is however in most applications totally negligible.
cvr::uniformDiscreteDistribution::uniformDiscreteDistribution | ( | ) |
Default constructor.
cvr::uniformDiscreteDistribution::uniformDiscreteDistribution | ( | const int | min, | |
const int | max | |||
) |
cvr::uniformDiscreteDistribution::uniformDiscreteDistribution | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
cvr::uniformDiscreteDistribution::uniformDiscreteDistribution | ( | const uniformDiscreteDistribution & | other | ) |
virtual cvr::uniformDiscreteDistribution::~uniformDiscreteDistribution | ( | ) | [virtual] |
Destructor.
virtual bool cvr::uniformDiscreteDistribution::apply | ( | int & | rnd | ) | [virtual] |
Get a random number.
Returns a random number distributed accordingly to the type of the current instance.
The uniformDiscreteDistribution can be used to obtain numbers in the interval [min(),max()].
rnd | double reference where the random number has to be left. |
Implements cvr::univariateDiscreteDistribution.
virtual uniformDiscreteDistribution* cvr::uniformDiscreteDistribution::clone | ( | ) | const [virtual] |
uniformDiscreteDistribution& cvr::uniformDiscreteDistribution::copy | ( | const uniformDiscreteDistribution & | other | ) |
virtual int cvr::uniformDiscreteDistribution::draw | ( | ) | [virtual] |
Virtual method to get a integer random number.
Returns a random number distributed accordingly to the type of the current instance.
The uniformDiscreteDistribution can be used to obtain numbers in the interval [min(),max()].
Implements cvr::univariateDiscreteDistribution.
parameters& cvr::uniformDiscreteDistribution::getParameters | ( | ) | [protected] |
const parameters& cvr::uniformDiscreteDistribution::getParameters | ( | ) | const |
virtual int cvr::uniformDiscreteDistribution::max | ( | ) | const [virtual] |
Virtual method to obtain the maximum possible number (inclusive) to be returned by this distribution.
Implements cvr::univariateDiscreteDistribution.
virtual int cvr::uniformDiscreteDistribution::min | ( | ) | const [virtual] |
Virtual method to obtain the minimum possible number (inclusive) to be returned by this distribution.
Implements cvr::univariateDiscreteDistribution.
virtual const std::string& cvr::uniformDiscreteDistribution::name | ( | ) | const [virtual] |
virtual uniformDiscreteDistribution* cvr::uniformDiscreteDistribution::newInstance | ( | ) | const [virtual] |
Returns a pointer to a new instance of this functor.
Implements cvr::univariateDiscreteDistribution.
uniformDiscreteDistribution& cvr::uniformDiscreteDistribution::operator= | ( | const uniformDiscreteDistribution & | other | ) |
int cvr::uniformDiscreteDistribution::rand | ( | ) |
Non-virtual method to get a integer random number.
Returns a random number distributed accordingly to the type of the current instance.
The uniformDiscreteDistribution can be used to obtain numbers in the interval [min(),max()].
Reimplemented from cvr::univariateDiscreteDistribution.
bool cvr::uniformDiscreteDistribution::setInterval | ( | const int | lower, | |
const int | upper | |||
) |
Change the interval, modifying the parameters as well.
bool cvr::uniformDiscreteDistribution::updateParameters | ( | ) | [virtual] |
int cvr::uniformDiscreteDistribution::delta_ [protected] |
delta_ = (maximum_ - minimum_ + 1)
int cvr::uniformDiscreteDistribution::maximum_ [protected] |
Shadow of the parameters.max;.
int cvr::uniformDiscreteDistribution::minimum_ [protected] |
Shadow of the parameters.min;.