From d842c5d28da14cb1ed3fb5e6bb4af76d8a5190a4 Mon Sep 17 00:00:00 2001 From: vrld Date: Tue, 26 Feb 2013 10:37:42 +0100 Subject: [PATCH] Fix box muller transform in common/math.cpp. Random numbers have to be in (0:1], not in [0:1). --- src/common/math.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/math.cpp b/src/common/math.cpp index facece23d..41c881518 100644 --- a/src/common/math.cpp +++ b/src/common/math.cpp @@ -24,8 +24,8 @@ float random_normal(float o) } // else: generate numbers using the Box-Muller transform - float a = sqrt(-2.0f * log(random())); - float b = float(LOVE_M_PI) * 2.0f * random(); + float a = sqrt(-2.0f * log(1. - random())); + float b = float(LOVE_M_PI) * 2.0f * (1. - random()); last_randnormal = a * cos(b); return a * sin(b) * o; }