-
Notifications
You must be signed in to change notification settings - Fork 3
/
random.hpp
30 lines (21 loc) · 996 Bytes
/
random.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef random_hpp
#define random_hpp
/*! \file
\brief Functions for returning various distributions of random numbers
*/
#include <boost/random.hpp>
#include <vector>
using std::vector;
//! Can be any of the generators described at http://www.boost.org/libs/random/random-generators.html
typedef boost::mt19937 OurGenerator;
//! Seed the random number generator, must be called before any of the other functions
void RandomSeed(OurGenerator::result_type seed);
//! Return uniformly distributed int's in [0..limit)
int RandomInt(int limit);
//! 80% of the time return uniformly distributed ints in [0..limit/5), otherwise return in [limit/5..limit)
int RandomInt8020(int limit);
//! Randomly choose between two consecutive integers floor(avg) and ceil(avg) so the average is avg
int RandomConsecutive(double avg);
//! Returns a random integer in [0..cf.size()) distributed by the cummulative probabilities given in cf
int RandomDiscrete(vector<double> const & cf);
#endif random_hpp