X-Boost  2.3.8
Functions
random.h File Reference

some methods about random number generation More...

Go to the source code of this file.

Functions

double drand (void)
 
int randbiased (double x)
 
int randslot (const double *slots, int n)
 
int nrand (int n)
 

Detailed Description

some methods about random number generation

Function Documentation

double drand ( void  )

return a random number between 0 and 1

int randbiased ( double  x)

return 0 or 1 with probability according to x

int randslot ( const double *  slots,
int  n 
)

extract a random slot according to slot PDF distribution.

double test[n];
test[0] = 0.25;
test[1] = 0.5;
test[2] = 0.75;
test[3] = 1.0;
int slot = randslot(test, 4);