diff options
author | André Nusser <andre.nusser@googlemail.com> | 2016-03-24 00:11:28 +0100 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2016-03-29 22:18:48 +0200 |
commit | 866b09992668f97af063dcd77dc5dd0e3a512b94 (patch) | |
tree | dfeffaa3eb1a559d746d04f3fbb7402e74d1b290 /src/powerlist.cc | |
parent | efe93864d53f72be4fa4dfe003f0f7578fc558e2 (diff) |
New Random class for convenient random number generation.
Diffstat (limited to 'src/powerlist.cc')
-rw-r--r-- | src/powerlist.cc | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/powerlist.cc b/src/powerlist.cc index efb1f97..b6640e9 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -51,18 +51,6 @@ #define SIZE 500 -// Box–Muller transform. -// See: http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform -static float box_muller_transform(float mean, float stddev) -{ - float U1 = (float)rand() / (float)RAND_MAX; - float U2 = (float)rand() / (float)RAND_MAX; - - float x = sqrt(-2.0 * log(U1)) * cos(2.0 * M_PI * U2); - - return mean + stddev * x; -} - PowerList::PowerList() { power_max = 0; @@ -242,7 +230,7 @@ Sample *PowerList::get(level_t level) again: // Select normal distributed value between // (stddev/2) and (power_span-stddev/2) - float lvl = box_muller_transform(mean, stddev); + float lvl = rand.normalDistribution(mean, stddev); // Adjust this value to be in range // (power_min+stddev/2) and (power_max-stddev/2) |