/** * Returns a random number from the distribution. */ public static double staticNextDouble(double alpha, double beta) { synchronized (shared) { return shared.nextDouble(alpha, beta); } }
/** * Constructs a Beta distribution. */ public Hyperbolic(double alpha, double beta, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setState(alpha, beta); }
/** * Sets the uniform random number generated shared by all <b>static</b> * methods. * * @param randomGenerator * the new uniform random number generator to be shared. */ private static void xstaticSetRandomGenerator(DoubleRandomEngine randomGenerator) { synchronized (shared) { shared.setRandomGenerator(randomGenerator); } } }
/** * Sets the uniform random number generated shared by all <b>static</b> * methods. * * @param randomGenerator * the new uniform random number generator to be shared. */ private static void xstaticSetRandomGenerator(DoubleRandomEngine randomGenerator) { synchronized (shared) { shared.setRandomGenerator(randomGenerator); } } }
/** * Constructs a Beta distribution. */ public Hyperbolic(double alpha, double beta, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setState(alpha, beta); }
/** * Returns a random number from the distribution. */ public static double staticNextDouble(double alpha, double beta) { synchronized (shared) { return shared.nextDouble(alpha, beta); } }
/** * Returns a hyperbolic distributed random number; bypasses the internal * state. */ public double nextDouble(double alpha, double beta) { /*********************************************************************** * * Hyperbolic Distribution - Non-Universal Rejection * * * ***************************************************************** * * FUNCTION : - hyplc.c samples a random number from the * hyperbolic * distribution with shape parameter a * and b valid for a>0 and |b|<a * using the * non-universal rejection method for log-concave * * densities. * REFERENCE : - L. Devroye (1986): Non-Uniform Random * Variate * Generation, Springer Verlag, New York. * SUBPROGRAM : - * drand(seed) ... (0,1)-Uniform generator with * unsigned long integer * *seed. * * **********************************************************************/ double a = alpha; double b = beta; if ((a_setup != a) || (b_setup != b)) { // SET-UP double mpa, mmb, mode; double amb; double a_, b_, a_1, b_1, pl; double help_1, help_2; amb = a * a - b * b; // a^2 - b^2 samb = Math.sqrt(amb); // -log(f(mode)) mode = b / samb; // mode help_1 = a * Math.sqrt(2.0 * samb + 1.0); help_2 = b * (samb + 1.0); mpa = (help_2 + help_1) / amb; // fr^-1(exp(-sqrt(a^2 - b^2) -
/** * Returns a hyperbolic distributed random number; bypasses the internal * state. */ public double nextDouble(double alpha, double beta) { /*********************************************************************** * * Hyperbolic Distribution - Non-Universal Rejection * * * ***************************************************************** * * FUNCTION : - hyplc.c samples a random number from the * hyperbolic * distribution with shape parameter a * and b valid for a>0 and |b|<a * using the * non-universal rejection method for log-concave * * densities. * REFERENCE : - L. Devroye (1986): Non-Uniform Random * Variate * Generation, Springer Verlag, New York. * SUBPROGRAM : - * drand(seed) ... (0,1)-Uniform generator with * unsigned long integer * *seed. * * **********************************************************************/ double a = alpha; double b = beta; if ((a_setup != a) || (b_setup != b)) { // SET-UP double mpa, mmb, mode; double amb; double a_, b_, a_1, b_1, pl; double help_1, help_2; amb = a * a - b * b; // a^2 - b^2 samb = Math.sqrt(amb); // -log(f(mode)) mode = b / samb; // mode help_1 = a * Math.sqrt(2.0 * samb + 1.0); help_2 = b * (samb + 1.0); mpa = (help_2 + help_1) / amb; // fr^-1(exp(-sqrt(a^2 - b^2) -