 A Discrete-Event Network Simulator Home Tutorials  ▼ Docs    ▼ Develop ▼ API
ns3::UniformVariable Class Reference

The uniform distribution RNG for NS-3. More...

`#include <random-variable.h>` Inheritance diagram for ns3::UniformVariable: Collaboration diagram for ns3::UniformVariable:

## Public Member Functions

UniformVariable ()
Creates a uniform random number generator in the range [0.0 . More...

UniformVariable (double s, double l)
Creates a uniform random number generator with the specified range. More...

uint32_t GetInteger (uint32_t s, uint32_t l)
Returns a random unsigned integer from the interval [s,l] including both ends. More...

double GetValue (void) const
call RandomVariable::GetValue More...

double GetValue (double s, double l)
Returns a random double with the specified range. More... Public Member Functions inherited from ns3::RandomVariable
RandomVariable ()

RandomVariable (const RandomVariable &o)

~RandomVariable ()

uint32_t GetInteger (void) const
Returns a random integer integer from the underlying distribution. More...

double GetValue (void) const
Returns a random double from the underlying distribution. More...

RandomVariableoperator= (const RandomVariable &o)

## Additional Inherited Members Protected Member Functions inherited from ns3::RandomVariable
RandomVariable (const RandomVariableBase &variable)

RandomVariableBasePeek (void) const

## Detailed Description

The uniform distribution RNG for NS-3.

This class supports the creation of objects that return random numbers from a fixed uniform distribution. It also supports the generation of single random numbers from various uniform distributions.

The low end of the range is always included and the high end of the range is always excluded.

x.GetValue (); //will always return numbers [0,10)

Definition at line 105 of file random-variable.h.

## Constructor & Destructor Documentation

 ns3::UniformVariable::UniformVariable ( )

Creates a uniform random number generator in the range [0.0 .

. 1.0).

Definition at line 262 of file random-variable.cc.

References NS_LOG_FUNCTION.

 ns3::UniformVariable::UniformVariable ( double s, double l )

Creates a uniform random number generator with the specified range.

Parameters
 s Low end of the range l High end of the range

Definition at line 267 of file random-variable.cc.

References NS_LOG_FUNCTION.

## Member Function Documentation

 uint32_t ns3::UniformVariable::GetInteger ( uint32_t s, uint32_t l )

Returns a random unsigned integer from the interval [s,l] including both ends.

Parameters
 s Low end of the range l High end of the range
Returns
A random unsigned integer value.

Definition at line 285 of file random-variable.cc.

References GetValue(), NS_ASSERT, and NS_LOG_FUNCTION. Here is the call graph for this function:

 double ns3::UniformVariable::GetValue ( void ) const
Returns
A floating point random value

Note: we have to re-implement this method here because the method is overloaded below for the two-argument variant and the c++ name resolution rules don't work well with overloads split between parent and child classes.

Definition at line 273 of file random-variable.cc.

References ns3::RandomVariable::GetValue(), and NS_LOG_FUNCTION.

Referenced by RngUniformTestCase::ChiSquaredTest(), GetInteger(), and main(). Here is the call graph for this function: Here is the caller graph for this function:

 double ns3::UniformVariable::GetValue ( double s, double l )

Returns a random double with the specified range.

Parameters
 s Low end of the range l High end of the range
Returns
A floating point random value

Definition at line 279 of file random-variable.cc.

References NS_LOG_FUNCTION, and ns3::RandomVariable::Peek(). Here is the call graph for this function:

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