// 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);
// }


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



/**
 * Gaussian random number generator.
 */
public interface GaussianRNG {
    GaussianRNG FAST_RNG = ZigguratFast.Z_256;
    GaussianRNG GENERAL_RNG = ZigguratGeneral.Z_256;

    /**
     * Generates a random value sampled from gaussian distribution (normal distribution).
     *
     * @param random random number generator
     * @return a random value
     */
    double generate(Random random);

    abstract class ZigguratBase {
        static double f(double x) {
            // f(x) = e^{-x^2 / 2}
            return exp(-0.5 * x * x);
        }

        static double tail(Random random, double r) {
            double _x, _y;
            do {
// 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/rng/GaussianRNG.java
import java.util.Random;
import static biz.k11i.util.MathFunctions.exp;
import static biz.k11i.util.MathFunctions.log;

package biz.k11i.rng;



/**
 * Gaussian random number generator.
 */
public interface GaussianRNG {
    GaussianRNG FAST_RNG = ZigguratFast.Z_256;
    GaussianRNG GENERAL_RNG = ZigguratGeneral.Z_256;

    /**
     * Generates a random value sampled from gaussian distribution (normal distribution).
     *
     * @param random random number generator
     * @return a random value
     */
    double generate(Random random);

    abstract class ZigguratBase {
        static double f(double x) {
            // f(x) = e^{-x^2 / 2}
            return exp(-0.5 * x * x);
        }

        static double tail(Random random, double r) {
            double _x, _y;
            do {
                _x = -log(random.nextDouble()) / r;