1 // Random number generation routines
2 // Copyright © 2009 The University of Chicago
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