diff --git a/math/src/main/java/smile/math/random/UniversalGenerator.java b/math/src/main/java/smile/math/random/UniversalGenerator.java
index <HASH>..<HASH> 100644
--- a/math/src/main/java/smile/math/random/UniversalGenerator.java
+++ b/math/src/main/java/smile/math/random/UniversalGenerator.java
@@ -190,18 +190,7 @@ public class UniversalGenerator implements RandomNumberGenerator {
             throw new IllegalArgumentException("n must be positive");

         }

         

-        // n is a power of 2

-        if ((n & -n) == n) {

-            return (int) ((n * (long) next(31)) >> 31);

-        }

-

-        int bits, val;

-        do {

-            bits = next(31);

-            val = bits % n;

-        } while (bits - val + (n - 1) < 0);

-        

-        return val;

+        return (int) (nextDouble() * n);

     }

     

     @Override
fix nextInt. UniversalGenerator generates uniformly distribute double values directly. The way of nextInt of MersenneTwister is improper here.