The log-normal distribution Random Number Generator (RNG) that allows stream numbers to be set deterministically. More...
#include <random-variable-stream.h>
Public Member Functions | |
LogNormalRandomVariable () | |
Creates a log-normal distribution RNG with the default values for mu and sigma. More... | |
uint32_t | GetInteger (uint32_t mu, uint32_t sigma) |
Returns a random unsigned integer from a log-normal distribution with the specified mu and sigma. More... | |
virtual uint32_t | GetInteger (void) |
Returns a random unsigned integer from a log-normal distribution with the current mu and sigma. More... | |
double | GetMu (void) const |
Returns the mu value for the log-normal distribution returned by this RNG stream. More... | |
double | GetSigma (void) const |
Returns the sigma value for the log-normal distribution returned by this RNG stream. More... | |
double | GetValue (double mu, double sigma) |
Returns a random double from a log-normal distribution with the specified mu and sigma. More... | |
virtual double | GetValue (void) |
Returns a random double from a log-normal distribution with the current mu and sigma. More... | |
![]() | |
RandomVariableStream () | |
virtual | ~RandomVariableStream () |
int64_t | GetStream (void) const |
Returns the stream number for this RNG stream. More... | |
bool | IsAntithetic (void) const |
Returns true if antithetic values should be generated. More... | |
void | SetAntithetic (bool isAntithetic) |
Specifies whether antithetic values should be generated. More... | |
void | SetStream (int64_t stream) |
Specifies the stream number for this RNG stream. More... | |
![]() | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
![]() | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
![]() | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
![]() | |
static TypeId | GetTypeId (void) |
![]() | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
![]() | |
static void | Cleanup (void) |
Noop. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Private Attributes | |
double | m_mu |
The mu value for the log-normal distribution returned by this RNG stream. More... | |
double | m_sigma |
The sigma value for the log-normal distribution returned by this RNG stream. More... | |
Additional Inherited Members | |
![]() | |
RngStream * | Peek (void) const |
Returns a pointer to the underlying RNG stream. More... | |
![]() | |
Object (const Object &o) | |
virtual void | DoDispose (void) |
This method is called by Object::Dispose or by the object's destructor, whichever comes first. More... | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
This method is invoked once all member attributes have been initialized. More... | |
The log-normal distribution Random Number Generator (RNG) that allows stream numbers to be set deterministically.
This class supports the creation of objects that return random numbers from a fixed log-normal distribution. It also supports the generation of single random numbers from various log-normal distributions.
LogNormalRandomVariable defines a random variable with a log-normal distribution. If one takes the natural logarithm of random variable following the log-normal distribution, the obtained values follow a normal distribution.
The probability density function is defined over the interval [0, ) as:
where
and
The and
parameters can be calculated instead if the mean and variance are known with the following equations:
, and,
Here is an example of how to use this class:
ns3::LogNormalRandomVariable is accessible through the following paths with Config::Set and Config::Connect:
No TraceSources are defined for this type.
Definition at line 1296 of file random-variable-stream.h.
ns3::LogNormalRandomVariable::LogNormalRandomVariable | ( | ) |
Creates a log-normal distribution RNG with the default values for mu and sigma.
Definition at line 772 of file random-variable-stream.cc.
References NS_LOG_FUNCTION.
uint32_t ns3::LogNormalRandomVariable::GetInteger | ( | uint32_t | mu, |
uint32_t | sigma | ||
) |
Returns a random unsigned integer from a log-normal distribution with the specified mu and sigma.
mu | Mu value for the log-normal distribution. |
sigma | Sigma value for the log-normal distribution. |
Note that antithetic values are being generated if m_isAntithetic is equal to true. If and
are uniform variables over [0,1], then the value that would be returned normally,
, is calculated as follows:
For the antithetic case, ) and
) are the distances that
and
would be from
. The antithetic value returned,
, is calculated as follows:
which now involves the distances and
are from 1.
Definition at line 853 of file random-variable-stream.cc.
References GetValue(), and NS_LOG_FUNCTION.
|
virtual |
Returns a random unsigned integer from a log-normal distribution with the current mu and sigma.
Note that antithetic values are being generated if m_isAntithetic is equal to true. If and
are uniform variables over [0,1], then the value that would be returned normally,
, is calculated as follows:
For the antithetic case, ) and
) are the distances that
and
would be from
. The antithetic value returned,
, is calculated as follows:
which now involves the distances and
are from 1.
Implements ns3::RandomVariableStream.
Definition at line 866 of file random-variable-stream.cc.
References GetValue(), m_mu, m_sigma, and NS_LOG_FUNCTION.
double ns3::LogNormalRandomVariable::GetMu | ( | void | ) | const |
Returns the mu value for the log-normal distribution returned by this RNG stream.
Definition at line 780 of file random-variable-stream.cc.
References m_mu, and NS_LOG_FUNCTION.
double ns3::LogNormalRandomVariable::GetSigma | ( | void | ) | const |
Returns the sigma value for the log-normal distribution returned by this RNG stream.
Definition at line 786 of file random-variable-stream.cc.
References m_sigma, and NS_LOG_FUNCTION.
|
static |
Definition at line 756 of file random-variable-stream.cc.
References m_mu, m_sigma, and ns3::TypeId::SetParent().
double ns3::LogNormalRandomVariable::GetValue | ( | double | mu, |
double | sigma | ||
) |
Returns a random double from a log-normal distribution with the specified mu and sigma.
mu | Mu value for the log-normal distribution. |
sigma | Sigma value for the log-normal distribution. |
Note that antithetic values are being generated if m_isAntithetic is equal to true. If and
are uniform variables over [0,1], then the value that would be returned normally,
, is calculated as follows:
For the antithetic case, ) and
) are the distances that
and
would be from
. The antithetic value returned,
, is calculated as follows:
which now involves the distances and
are from 1.
Definition at line 819 of file random-variable-stream.cc.
References ns3::RandomVariableStream::IsAntithetic(), ns3::normal, NS_LOG_FUNCTION, ns3::RandomVariableStream::Peek(), ns3::RngStream::RandU01(), and sample-rng-plot::x.
Referenced by RandomVariableStreamLogNormalTestCase::ChiSquaredTest(), RandomVariableStreamLogNormalAntitheticTestCase::ChiSquaredTest(), RandomVariableStreamLogNormalTestCase::DoRun(), and RandomVariableStreamLogNormalAntitheticTestCase::DoRun().
|
virtual |
Returns a random double from a log-normal distribution with the current mu and sigma.
Note that antithetic values are being generated if m_isAntithetic is equal to true. If and
are uniform variables over [0,1], then the value that would be returned normally,
, is calculated as follows:
For the antithetic case, ) and
) are the distances that
and
would be from
. The antithetic value returned,
, is calculated as follows:
which now involves the distances and
are from 1.
Note that we have to re-implement this method here because the method is overloaded above for the two-argument variant and the c++ name resolution rules don't work well with overloads split between parent and child classes.
Implements ns3::RandomVariableStream.
Definition at line 860 of file random-variable-stream.cc.
References m_mu, m_sigma, and NS_LOG_FUNCTION.
Referenced by GetInteger().
|
private |
The mu value for the log-normal distribution returned by this RNG stream.
Definition at line 1462 of file random-variable-stream.h.
Referenced by GetInteger(), GetMu(), GetTypeId(), and GetValue().
|
private |
The sigma value for the log-normal distribution returned by this RNG stream.
Definition at line 1465 of file random-variable-stream.h.
Referenced by GetInteger(), GetSigma(), GetTypeId(), and GetValue().