src/core/reinforcement/policy/executablepolicy/MCTSPolicy.java
private double generateGamma (double alpha, double beta) {
            if (alpha > 1) {
                double d = alpha - 1 / (double)3;
                double c = 1 / Math.sqrt(9 * d);
                while (true) {
                    double Z = random.nextGaussian();
                    if (Z > - 1 / c) {
                        double U = random.nextDouble();
                        double V = Math.pow(1 + c * Z, 3);
                        if (Math.log(U) < 0.5 * Math.pow(Z, 2) + d - d * V + d * Math.log(V)) return d * V / beta;
                    }
                }
            }
            else return generateGamma(alpha + 1, beta) * Math.pow(random.nextDouble(), 1 / alpha);
        }
/**
         * Generates random variable from gamma distribution.<br>
         * Reference: https://www.hongliangjie.com/2012/12/19/how-to-generate-gamma-random-variables/
         *
         * @param alpha alpha parameter
         * @param beta beta parameter
         * @return random variable from gamma distribution
         */


@param alpha alpha parameter
@param beta beta parameter
@return random variable from gamma distribution
@param alpha alpha parameter @param beta beta parameter @return random variable from gamma distribution
private double generateGamma (double alpha, double beta) {
            if (alpha > 1) {
                double d = alpha - 1 / (double)3;
                double c = 1 / Math.sqrt(9 * d);
                while (true) {
                    double Z = random.nextGaussian();
                    if (Z > - 1 / c) {
                        double U = random.nextDouble();
                        double V = Math.pow(1 + c * Z, 3);
                        if (Math.log(U) < 0.5 * Math.pow(Z, 2) + d - d * V + d * Math.log(V)) return d * V / beta;
                    }
                }
            }
            else return generateGamma(alpha + 1, beta) * Math.pow(random.nextDouble(), 1 / alpha);
        }
private double generateGamma ( double alpha , double beta ) { if ( alpha > 1 ) { double d = alpha - 1 / ( double ) 3 ; double c = 1 / Math . sqrt ( 9 * d ) ; while ( true ) { double Z = random . nextGaussian ( ) ; if ( Z > - 1 / c ) { double U = random . nextDouble ( ) ; double V = Math . pow ( 1 + c * Z , 3 ) ; if ( Math . log ( U ) < 0.5 * Math . pow ( Z , 2 ) + d - d * V + d * Math . log ( V ) ) return d * V / beta ; } } } else return generateGamma ( alpha + 1 , beta ) * Math . pow ( random . nextDouble ( ) , 1 / alpha ) ; }
Generates random variable from gamma distribution.<br>
 Reference: https://www.hongliangjie.com/2012/12/19/how-to-generate-gamma-random-variables
Generates random variable from gamma distribution . <br > Reference : https : // www . hongliangjie . com / 2012 / 12 / 19 / how - to - generate - gamma - random - variables