HowManyAreAnalyzed(): use status_user_agent to report progress
[linguistica.git] / random.h
blobe05ebf925b27f9dd48880066f3f64d3773f37fc6
1 // Random number generation routines
2 // Copyright © 2009 The University of Chicago
3 #ifndef RANDOM_H
4 #define RANDOM_H
6 #include <cstdlib>
8 namespace linguistica {
10 /// random float chosen uniformly from the interval [-1/2, 1/2]
11 /// requires: std::srand has already been called to seed the RNG
12 inline float random_small_float()
14 // let the RNG calm down a bit
15 for (int i = 0; i < 25; ++i)
16 static_cast<void>(std::rand());
17 return (static_cast<float>(std::rand()) /
18 static_cast<float>(RAND_MAX)) - float(0.5);
21 } // namespace linguistica
23 #endif // RANDOM_H