UniformRandom Class Reference

Inheritance diagram for UniformRandom:

RealRandom MTRand List of all members.

Detailed Description

Unform random number generator.

This class generates real-valued random numbers uniformly distributed over a given range, [low, high).

Author:
Bill Smart
Date:
November 2001
Version:
1.0

Definition at line 264 of file Random.H.

Public Member Functions

 UniformRandom (const double low=1.0, const double high=0.0, const unsigned long seed=1UL)
Generate samples
double number ()
 Generate a sample from the random variable.
Moments of the random variable
double mean () const
double variance () const
double stdDev () const
Parameters of the random variable
double lowValue () const
double highValue () const
double range () const
Change parameters of the random variable
void setLowValue (const double low)
void setHighValue (const double high)
void setValues (const double low, const double high)

Private Attributes

double m_low
double m_range


Constructor & Destructor Documentation

UniformRandom ( const double  low = 1.0,
const double  high = 0.0,
const unsigned long  seed = 1UL 
) [inline]

Alocates an instance of the class, sets the high and low limits for the numbers to be generated, and sets the random number seed.

Parameters:
low Low value for the generated numbers.
high High value for the generated numbers.
seed Random number seed. Do not set this to zero.
Note:
This constructor can be used in three different ways. The obvious one is
    UniformRandom gen(low, high); 
which generates numbers in the range [low, high). It can also be used with a single parameter
    UniformRandom gen(high); 
to generate numbers from the range [0, high). The final way is to use all three of the default values which generates numbers in the range [0.0, 1.0).

Definition at line 281 of file Random.H.


Member Function Documentation

double number (  )  [inline, virtual]

Generate a sample from the random variable.

This function generates a sample from the random variable represented by the class instance.

Returns:
A sample from the random variable.

Implements RealRandom.

Definition at line 288 of file Random.H.

References m_low, m_range, and MTRand::rand().

double mean (  )  const [inline, virtual]

Returns:
The mean of the random variable.

Implements RealRandom.

Definition at line 293 of file Random.H.

References m_low, and m_range.

double variance (  )  const [inline, virtual]

Returns:
The variance of the random variable.

Implements RealRandom.

Definition at line 294 of file Random.H.

References m_range.

Referenced by stdDev().

double stdDev (  )  const [inline, virtual]

Returns:
The standard deviation of the random variable.

Implements RealRandom.

Definition at line 295 of file Random.H.

References variance().

double lowValue (  )  const [inline]

Returns:
The low value of the range of numbers that can be generated.

Definition at line 301 of file Random.H.

References m_low.

double highValue (  )  const [inline]

Returns:
The high value of the range of numbers that can be generated.

Definition at line 303 of file Random.H.

References m_low, and m_range.

double range (  )  const [inline]

Returns:
The range of the numbers that can be generated.

Definition at line 305 of file Random.H.

References m_range.

void setLowValue ( const double  low  )  [inline]

Set the low value of the random variable.

Parameters:
low New low value.

Definition at line 312 of file Random.H.

References m_low.

Referenced by setValues().

void setHighValue ( const double  high  )  [inline]

Set the high value of the random variable.

Parameters:
high New high value.

Definition at line 315 of file Random.H.

References m_low, and m_range.

Referenced by setValues().

void setValues ( const double  low,
const double  high 
) [inline]

Set the both the low and high values of the random variable.

Parameters:
low Low high value.
high New high value.

Definition at line 319 of file Random.H.

References setHighValue(), and setLowValue().


Member Data Documentation

double m_low [private]

Definition at line 324 of file Random.H.

Referenced by highValue(), lowValue(), mean(), number(), setHighValue(), and setLowValue().

double m_range [private]

Definition at line 325 of file Random.H.

Referenced by highValue(), mean(), number(), range(), setHighValue(), and variance().


The documentation for this class was generated from the following file:
Generated on Thu Feb 1 15:31:55 2007 for WURDE by  doxygen 1.5.1