CVR-Lib last update 20 Sep 2009

cvr::uniformDiscreteDistribution Class Reference
[Discrete random distributions]

Class uniformDiscreteDistribution. More...

#include <cvrUniformDiscreteDistribution.h>

Inheritance diagram for cvr::uniformDiscreteDistribution:

Inheritance graph
[legend]
Collaboration diagram for cvr::uniformDiscreteDistribution:

Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 The parameters for the class uniformDiscreteDistribution. More...

Public Member Functions

 uniformDiscreteDistribution ()
 uniformDiscreteDistribution (const int min, const int max)
 uniformDiscreteDistribution (const parameters &par)
 uniformDiscreteDistribution (const uniformDiscreteDistribution &other)
virtual ~uniformDiscreteDistribution ()
virtual bool apply (int &rnd)
virtual int draw ()
int rand ()
virtual int max () const
virtual int min () const
bool setInterval (const int lower, const int upper)
uniformDiscreteDistributioncopy (const uniformDiscreteDistribution &other)
uniformDiscreteDistributionoperator= (const uniformDiscreteDistribution &other)
virtual const std::string & name () const
virtual
uniformDiscreteDistribution
clone () const
virtual
uniformDiscreteDistribution
newInstance () const
const parametersgetParameters () const
bool updateParameters ()

Protected Member Functions

parametersgetParameters ()

Protected Attributes

int minimum_
int maximum_
int delta_


Detailed Description

Class uniformDiscreteDistribution.

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.

See also:
uniformDiscreteDistribution::parameters.

Constructor & Destructor Documentation

cvr::uniformDiscreteDistribution::uniformDiscreteDistribution (  ) 

Default constructor.

cvr::uniformDiscreteDistribution::uniformDiscreteDistribution ( const int  min,
const int  max 
)

Constructor with a given interval.

Parameters:
min lower interval bound.
max higher interval bound.

cvr::uniformDiscreteDistribution::uniformDiscreteDistribution ( const parameters par  ) 

Construct a functor using the given parameters.

cvr::uniformDiscreteDistribution::uniformDiscreteDistribution ( const uniformDiscreteDistribution other  ) 

Copy constructor.

Parameters:
other the object to be copied

virtual cvr::uniformDiscreteDistribution::~uniformDiscreteDistribution (  )  [virtual]

Destructor.


Member Function Documentation

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()].

Parameters:
rnd double reference where the random number has to be left.
Returns:
true if apply successful or false otherwise.

Implements cvr::univariateDiscreteDistribution.

virtual uniformDiscreteDistribution* cvr::uniformDiscreteDistribution::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements cvr::univariateDiscreteDistribution.

uniformDiscreteDistribution& cvr::uniformDiscreteDistribution::copy ( const uniformDiscreteDistribution other  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

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()].

Returns:
a random float number.

Implements cvr::univariateDiscreteDistribution.

parameters& cvr::uniformDiscreteDistribution::getParameters (  )  [protected]

Returns used parameters.

Reimplemented from cvr::parametersManager.

const parameters& cvr::uniformDiscreteDistribution::getParameters (  )  const

Returns used parameters.

Reimplemented from cvr::randomDistribution.

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]

Returns the complete name of the functor class.

Reimplemented from cvr::randomDistribution.

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  ) 

Alias for copy member.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

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()].

Returns:
a random float number.

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]

Update parameters.

Reimplemented from cvr::randomDistribution.


Member Data Documentation

delta_ = (maximum_ - minimum_ + 1)

Shadow of the parameters.max;.

Shadow of the parameters.min;.


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:09:06 2009 for CVR-Lib by Doxygen 1.5.8