MIRA
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Friends | List of all members
RandomGeneratorSingleton Class Reference

Singleton class for generating random numbers. More...

#include <math/Random.h>

Inheritance diagram for RandomGeneratorSingleton:
Inheritance graph
[legend]

Public Types

typedef Base::Type Type
 

Public Member Functions

void seed (uint64 seed=0)
 Seed the random number generator. More...
 
double random ()
 Platform independent generation of random, double precision floating point random numbers in the interval [0.0, 1.0) More...
 
template<typename T >
uniform (T min, T max)
 Generate uniform distributed random numbers in the interval [min, max) More...
 
double normal (double sigma=1.0)
 Generate standard normally distributed random numbers using a source of uniformly distributed random numbers. More...
 
double gaussian (double sigma=1.0)
 deprecated, use normal() instead. More...
 

Static Public Member Functions

static Typeinstance ()
 Returns a reference to the singleton instance. More...
 
static bool isDestroyed ()
 Returns true, if the singleton was already destroyed. More...
 

Static Protected Member Functions

static TypemakeInstance ()
 
static void destroyInstance (void)
 

Friends

struct mira::singleton::CreateUsingNew< RandomGeneratorSingleton >
 

Detailed Description

Singleton class for generating random numbers.

Use the MIRA_RANDOM macro to access the singleton.

Usage:

#include <math/Random.h>
...
// sample uniform random number between 10 and 30
int rndnumber1 = MIRA_RANDOM.uniform(10,30);
// sample normal distributed random number with sigma=2
float rndnumber2 = MIRA_RANDOM.normal(2.0);

Member Typedef Documentation

◆ Type

typedef Base::Type Type
inherited

Member Function Documentation

◆ seed()

void seed ( uint64  seed = 0)
inline

Seed the random number generator.

Is done automatically when creating the singleton

Parameters
[in]seedThe seed value: Default = 0 uses the current time for seeding the random generator. Therefore, the result will be a non-reproducible pseudo-random sequence. All other values allow to seed the random generator with a specific value and will result in a reproducible pseudo-random sequence.

◆ random()

double random ( )
inline

Platform independent generation of random, double precision floating point random numbers in the interval [0.0, 1.0)

◆ uniform()

T uniform ( min,
max 
)
inline

Generate uniform distributed random numbers in the interval [min, max)

◆ normal()

double normal ( double  sigma = 1.0)
inline

Generate standard normally distributed random numbers using a source of uniformly distributed random numbers.

Sigma must be >= 0.0!

◆ gaussian()

double gaussian ( double  sigma = 1.0)
inline

deprecated, use normal() instead.

◆ instance()

static Type& instance ( )
inlinestaticinherited

Returns a reference to the singleton instance.

Exceptions
XSingletonIf the singleton was already destroyed (dead reference) or not yet created (when using ExplicitInstantiation).

◆ isDestroyed()

static bool isDestroyed ( )
inlinestaticinherited

Returns true, if the singleton was already destroyed.

Trying to access it will result in an exception.

◆ makeInstance()

static Type* makeInstance ( )
inlinestaticprotectedinherited

◆ destroyInstance()

static void destroyInstance ( void  )
inlinestaticprotectedinherited

Friends And Related Function Documentation

◆ mira::singleton::CreateUsingNew< RandomGeneratorSingleton >


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