Virtual Belgium  2.0
A micro-simulation platform for the Belgian population
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Random.hpp File Reference

Random number generators and related tools. More...

#include <iostream>
#include <vector>
#include <cmath>
#include <stdexcept>

Go to the source code of this file.

Classes

struct  draw_2d
 
struct  dist_param
 
struct  dist_param_mixture
 
struct  dist_param_2d
 
struct  dist_param_mixture_2d
 
struct  Ranq1
 Simplest and fastest random number generator recommended by Numerical Recipes. More...
 
struct  Ranfib
 Fast and good random number generator (see Numerical Recipes). More...
 
struct  Normaldev
 Fast Random number generator for normal distribution (Numerical Recipes). More...
 
struct  LogNormaldev
 Fast Random number generator for log-normal distribution (Numerical Recipes). More...
 
struct  MixtureNormal
 Fast Random number generator for mixture of normal distribution (Numerical Recipes). More...
 
struct  MixtureLogNormal
 Fast Random number generator for mixture of log-normal distribution (Numerical Recipes). More...
 
struct  MixtureLogNormal2D
 Fast Random number generator for mixture of bivariate log-normal distribution (Numerical Recipes). More...
 
class  SingletonRnd< T >
 SingletonRnd class for the RandomGenerators class. More...
 
class  RandomGenerators
 Random generators. More...
 

Typedefs

typedef struct draw_2d draw_2d
 A simple structure for returning a 2d draw. More...
 
typedef struct dist_param dist_param
 A structure for storing the parameters of an univariate distribution. More...
 
typedef struct dist_param_mixture dist_param_mixture
 A structure for storing the parameters of a mixture of univariate distributions. More...
 
typedef struct dist_param_2d dist_param_2d
 A structure for storing the parameters of a bivariate distribution (X_1, X_2). More...
 
typedef struct
dist_param_mixture_2d 
dist_param_mixture_2d
 A structure for storing the parameters of a mixture of bivariate distributions. More...
 

Functions

template<typename T >
int draw_discrete (std::vector< T > freq)
 Randomly draws a class identifier within an empirical density function. More...
 
template<typename T >
int draw_discrete (std::vector< T > freq, int lo_bound, int up_bound)
 Randomly draws a class identifier within an interval of an empirical density function. More...
 
float norm_rand (float mu, float sigma)
 Random number generator following a normal distribution (DEPRECIATED) More...
 
float norm_rand (float mu, float sigma, float max)
 Random number generator following a bounded normal distribution (DEPRECIATED) More...
 
float log_rand (float mu, float sigma)
 Random number generator following a log-normal distribution (DEPRECIATED) More...
 
float log_rand (float mu, float sigma, float max)
 Random number generator following a bounded log-normal distribution (DEPRECIATED) More...
 

Detailed Description

Random number generators and related tools.

Typedef Documentation

typedef struct dist_param dist_param

A structure for storing the parameters of an univariate distribution.

This structure saves the location, scale parameters and upper bound of an univariate distribution.

typedef struct dist_param_2d dist_param_2d

A structure for storing the parameters of a bivariate distribution (X_1, X_2).

This structure saves the location vector, the (Choleski decomposition of the) covariance matrix and the upper bounds vector of a bivariate distribution.

A structure for storing the parameters of a mixture of univariate distributions.

This structure saves the the location and scale parameters of the components and the upper bound of an univariate distribution.

A structure for storing the parameters of a mixture of bivariate distributions.

This structure saves the location vectors, the Choleski decomposition of the covariance matrices and the upper bounds vectors of the components of bivariate mixture distribution.

typedef struct draw_2d draw_2d

A simple structure for returning a 2d draw.

Function Documentation

template<typename T >
int draw_discrete ( std::vector< T >  freq)

Randomly draws a class identifier within an empirical density function.

Parameters
freqthe empirical density function in which the random draw is done.
Returns
the class identifier of freq randomly draw.
template<typename T >
int draw_discrete ( std::vector< T >  freq,
int  lo_bound,
int  up_bound 
)

Randomly draws a class identifier within an interval of an empirical density function.

Parameters
freqthe empirical density function in wich the random draw is done.
lo_boundthe lower bound index of freq to consider.
up_boundthe upper bound index of freq to consider.
Returns
the class identifier of freq randomly draw.
float log_rand ( float  mu,
float  sigma 
)

Random number generator following a log-normal distribution (DEPRECIATED)

float log_rand ( float  mu,
float  sigma,
float  max 
)

Random number generator following a bounded log-normal distribution (DEPRECIATED)

float norm_rand ( float  mu,
float  sigma 
)

Random number generator following a normal distribution (DEPRECIATED)

float norm_rand ( float  mu,
float  sigma,
float  max 
)

Random number generator following a bounded normal distribution (DEPRECIATED)