// 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 pow(double value, double power) {
//     return JafamaMath.pow(value, power);
// }


import java.util.Random;
import static biz.k11i.util.MathFunctions.exp;
import static biz.k11i.util.MathFunctions.log;
import static biz.k11i.util.MathFunctions.pow;

                    double logM = u > v ? u : v;
                    u -= logM;
                    v -= logM;

                    return exp(u - log(exp(u) + exp(v)));
                }
            }
        }
    }

    /**
     * Implementation of Beta random number generator using Sakasegawa's B00 algorithm.
     * <p>
     * Sakasegawa, H.
     * <i>"Stratified rejection and squeeze method for generating beta random numbers."</i>
     * Annals of the Institute of Statistical Mathematics 35.1 (1983): 291-302.
     * </p>
     */
    static class B00 implements BetaRNG {
        static final BetaRNG INSTANCE = new B00();

        @Override
        public double generate(Random random, double alpha, double beta) {
            double t = (1 - alpha) / (2 - alpha - beta);
            double s = (beta - alpha) * (1 - alpha - beta);
            double r = alpha * (1 - alpha);
            t -= ((s * t + 2 * r) * t - r) / 2 * (s * t + r);
            double p = t / alpha;
            double q = (1 - t) / beta;
// 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 pow(double value, double power) {
//     return JafamaMath.pow(value, power);
// }


// Path: fast-rng/src/main/java/biz/k11i/rng/BetaRNG.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.pow;


                    double logM = u > v ? u : v;
                    u -= logM;
                    v -= logM;

                    return exp(u - log(exp(u) + exp(v)));
                }
            }
        }
    }

    /**
     * Implementation of Beta random number generator using Sakasegawa's B00 algorithm.
     * <p>
     * Sakasegawa, H.
     * <i>"Stratified rejection and squeeze method for generating beta random numbers."</i>
     * Annals of the Institute of Statistical Mathematics 35.1 (1983): 291-302.
     * </p>
     */
    static class B00 implements BetaRNG {
        static final BetaRNG INSTANCE = new B00();

        @Override
        public double generate(Random random, double alpha, double beta) {
            double t = (1 - alpha) / (2 - alpha - beta);
            double s = (beta - alpha) * (1 - alpha - beta);
            double r = alpha * (1 - alpha);
            t -= ((s * t + 2 * r) * t - r) / 2 * (s * t + r);
            double p = t / alpha;
            double q = (1 - t) / beta;
            s = pow((1 - t), beta - 1);