Skip to content

Commit 5f16efb

Browse files
committed
FIX: Fix the Ziggurat for double to generates negative samples
In the Ziggurat method, the polarity of normal RV must be chosen at random. Previously, this Ziggurat implementation always generates a positive value. This RV obviously does not follows the normal distribution. Now it has positive and negative samples and is normally-distributed.
1 parent b08a05c commit 5f16efb

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

randomstate/distributions.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ static inline double gauss_zig_double(aug_state* state)
141141
x = rabs * wi_double[idx];
142142
if (sign & 0x1)
143143
x = -x;
144-
if (r & 0x1)
145-
x = -x;
146144
if (rabs < ki_double[idx])
147145
return x; // # 99.3% of the time return here
148146
if (idx == 0)

0 commit comments

Comments
 (0)