Monday, January 24, 2005

[segway] random

there is a wrapped random generator in segway/shared/random.{cc,h}

to use it, see detail in random.h

some examples:

#include "random.h"
class random my_random;

my_random.randomize();

// gaussian distribution
my_x = my_random.gaussian32();

// uniform random number(unsigned integer) in [0, MAX)
my_y = my_random.uint32(MAX);

// uniform random number (real) in [0,1)
my_y = my_random.real32(MAX);

// uniform random number (real) in [-1,1)
my_y = my_random.sreal32(MAX);