Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Arak::Util::Random Class Reference

#include <random.hpp>

List of all members.


Detailed Description

A simple wrapper around the GNU Scientific Library pseudorandom number generator.

See also:
http://www.gnu.org/software/gsl/manual/gsl-ref_17.html

Definition at line 19 of file random.hpp.

Public Member Functions

 Random ()
 Default constructor.

 Random (const Random &other)
 Copy constructor.

 ~Random ()
 Destructor.

double uniform ()
 Returns a pseudorandom real number in the range $[0, 1)$.

double uniform (double a, double b)
 Returns a pseudorandom real number in the range $[a, b)$.

unsigned long int uniform (unsigned long int n)
 Returns a pseudorandom integer in the range $[0, n)$.

bool bernoulli (double p=0.5)
 Returns true with probability $p$, and false with probability $1 - p$.

unsigned int binomial (double p, unsigned int n)
 Returns a sample from the binomial distribution with success probability $p$ and number of trials $n$.

Geometry::Point uniform (const Geometry::Point &source, const Geometry::Point &target)
 Samples a point uniformly from a line segment.

Geometry::Point uniform (const Geometry::Segment &s)
 Samples a point uniformly from a line segment.

Geometry::Point uniform (const Geometry::Triangle &t)
 Samples a point uniformly from a triangle.

void write (std::ostream &out) const
 Writes a short description of this PRNG to the supplied stream.


Protected Attributes

gsl_rng * r
 The underlying pseudorandom number generator.


Constructor & Destructor Documentation

Arak::Util::Random::Random  )  [inline]
 

Default constructor.

If the environment variables GSL_RNG_TYPE and/or GSL_RNG_SEED are specified, then their values are used to determine the type and initial state of the pseudorandom number generator. The defaults are to use the Mersenne Twister PRNG with the seed 0.

Definition at line 37 of file random.hpp.

Arak::Util::Random::Random const Random other  )  [inline]
 

Copy constructor.

Parameters:
other another PRNG of the same type as this one

Definition at line 49 of file random.hpp.

Arak::Util::Random::~Random  )  [inline]
 

Destructor.

Definition at line 54 of file random.hpp.


Member Function Documentation

bool Arak::Util::Random::bernoulli double  p = 0.5  )  [inline]
 

Returns true with probability $p$, and false with probability $1 - p$.

Definition at line 85 of file random.hpp.

References uniform().

Referenced by Arak::CN94Proposal::sampleMoveBdVertexPastCorner(), Arak::ModifiedCN94Proposal::sampleRecolor(), Arak::CN94Proposal::sampleRecolor(), and Arak::ModifiedCN94Proposal::sampleSlideInteriorVertex().

unsigned int Arak::Util::Random::binomial double  p,
unsigned int  n
[inline]
 

Returns a sample from the binomial distribution with success probability $p$ and number of trials $n$.

Definition at line 93 of file random.hpp.

Geometry::Point Arak::Util::Random::uniform const Geometry::Triangle t  )  [inline]
 

Samples a point uniformly from a triangle.

Parameters:
t the triangle
Returns:
a point drawn u.a.r. from t
See also:
Turk G.; Generating Random Points in Triangles; Graphics Gems I, p.24

Definition at line 135 of file random.hpp.

References Arak::Geometry::Point, Arak::Geometry::Triangle, uniform(), and Arak::Geometry::Vector.

Geometry::Point Arak::Util::Random::uniform const Geometry::Segment s  )  [inline]
 

Samples a point uniformly from a line segment.

Parameters:
s the segment
Returns:
a point drawn u.a.r. from s

Definition at line 123 of file random.hpp.

References Arak::Geometry::Point, Arak::Geometry::Segment, and uniform().

Geometry::Point Arak::Util::Random::uniform const Geometry::Point source,
const Geometry::Point target
[inline]
 

Samples a point uniformly from a line segment.

Parameters:
source the source of the line segment
target the target of the line segment
Returns:
a point drawn u.a.r. from s

Definition at line 104 of file random.hpp.

References Arak::Geometry::Point, uniform(), and Arak::Geometry::Vector.

unsigned long int Arak::Util::Random::uniform unsigned long int  n  )  [inline]
 

Returns a pseudorandom integer in the range $[0, n)$.

Definition at line 77 of file random.hpp.

double Arak::Util::Random::uniform double  a,
double  b
[inline]
 

Returns a pseudorandom real number in the range $[a, b)$.

Definition at line 68 of file random.hpp.

double Arak::Util::Random::uniform  )  [inline]
 

Returns a pseudorandom real number in the range $[0, 1)$.

Definition at line 61 of file random.hpp.

Referenced by Arak::AnnealedMarkovChain< MarkovChainTraits >::advance(), Arak::MarkovChain< ArakMarkovChainTraits >::advance(), bernoulli(), Arak::Coloring::randomPoint(), Arak::Coloring::Edge::randomPoint(), Arak::CN94Proposal::sample(), Arak::ModifiedCN94Proposal::sampleBoundaryTriangleBirth(), Arak::CN94Proposal::sampleBoundaryTriangleBirth(), Arak::CN94Proposal::sampleBoundaryTriangleDeath(), Arak::CN94Proposal::sampleInCastingBox(), Arak::CN94Proposal::sampleInteriorVertexBirth(), Arak::ModifiedCN94Proposal::sampleMoveInteriorVertex(), Arak::CN94Proposal::sampleMoveVertexAlongBd(), Arak::ModifiedCN94Proposal::sampleRecolor(), Arak::CN94Proposal::sampleRecolor(), Arak::ModifiedCN94Proposal::sampleSlideInteriorVertex(), and uniform().

void Arak::Util::Random::write std::ostream &  out  )  const [inline]
 

Writes a short description of this PRNG to the supplied stream.

Definition at line 155 of file random.hpp.

Referenced by operator<<().


Member Data Documentation

gsl_rng* Arak::Util::Random::r [protected]
 

The underlying pseudorandom number generator.

Definition at line 26 of file random.hpp.


The documentation for this class was generated from the following file:
Generated on Wed May 25 14:41:42 2005 for Arak by doxygen 1.3.6