// Path: fast-rng/src/main/java/biz/k11i/util/MathFunctions.java
// public static final double exp(double value) {
//     return JafamaMath.exp(value);
// }
// 
// Path: fast-rng/src/main/java/biz/k11i/util/MathFunctions.java
// public static final double log(double value) {
//     return JafamaMath.log(value);
// }
// 
// Path: fast-rng/src/main/java/biz/k11i/util/MathFunctions.java
// public static final double log1p(double value) {
//     return JafamaMath.log1p(value);
// }


import java.util.Random;
import static biz.k11i.util.MathFunctions.exp;
import static biz.k11i.util.MathFunctions.log;
import static biz.k11i.util.MathFunctions.log1p;
            k[N - 1] = (long) Math.floor(r / w[N - 1]);
            f[N - 1] = exp(-r);

            double x = r;
            for (int i = N - 2; i >= 1; i--) {
                x = finv(x, v);
                w[i - 1] = x / b;
                k[i] = (long) Math.floor(x / w[i]);
                f[i] = exp(-x);
            }

            k[0] = 0;
            f[0] = 1;
        }

        @Override
        double generate(Random random, int recursiveCount) {
            while (true) {
                long u = random.nextLong();
                int i = (int) (u & INDEX_BIT_MASK);
                u >>>= INDEX_BITS;

                if (u < k[i]) {
                    return u * w[i];
                }

                if (i == TAIL_INDEX) {
                    if (recursiveCount < 2) {
                        return R + generate(random, recursiveCount + 1);
                    }
// Path: fast-rng/src/main/java/biz/k11i/util/MathFunctions.java
// public static final double exp(double value) {
//     return JafamaMath.exp(value);
// }
// 
// Path: fast-rng/src/main/java/biz/k11i/util/MathFunctions.java
// public static final double log(double value) {
//     return JafamaMath.log(value);
// }
// 
// Path: fast-rng/src/main/java/biz/k11i/util/MathFunctions.java
// public static final double log1p(double value) {
//     return JafamaMath.log1p(value);
// }


// Path: fast-rng/src/main/java/biz/k11i/rng/ExponentialRNG.java
import java.util.Random;
import static biz.k11i.util.MathFunctions.exp;
import static biz.k11i.util.MathFunctions.log;
import static biz.k11i.util.MathFunctions.log1p;

            k[N - 1] = (long) Math.floor(r / w[N - 1]);
            f[N - 1] = exp(-r);

            double x = r;
            for (int i = N - 2; i >= 1; i--) {
                x = finv(x, v);
                w[i - 1] = x / b;
                k[i] = (long) Math.floor(x / w[i]);
                f[i] = exp(-x);
            }

            k[0] = 0;
            f[0] = 1;
        }

        @Override
        double generate(Random random, int recursiveCount) {
            while (true) {
                long u = random.nextLong();
                int i = (int) (u & INDEX_BIT_MASK);
                u >>>= INDEX_BITS;

                if (u < k[i]) {
                    return u * w[i];
                }

                if (i == TAIL_INDEX) {
                    if (recursiveCount < 2) {
                        return R + generate(random, recursiveCount + 1);
                    }
                    return R - log1p(-random.nextDouble());