/** * Returns a random number from the distribution. */ public static double staticNextDouble(double alpha, double beta) { synchronized (shared) { return shared.nextDouble(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 beta distributed random number; bypasses the internal state. */ public double nextDouble(double alpha, double beta) { /*********************************************************************** * * Beta Distribution - Stratified Rejection/Patchwork Rejection * * * ***************************************************************** For * parameters a < 1 , b < 1 and a < 1 < b or b < 1 < a * the stratified * rejection methods b00 and b01 of Sakasegawa are * used. Both * procedures employ suitable two-part power functions * from which * samples can be obtained by inversion. * If a > 1 , b > 1 (unimodal * case) the patchwork rejection * method b1prs of Zechner/Stadlober is * utilized: * The area below the density function f(x) in its body is * * rearranged by certain point reflections. Within a large center * * interval variates are sampled efficiently by rejection from * uniform * hats. Rectangular immediate acceptance regions speed * up the * generation. The remaining tails are covered by * exponential * functions. * If (a-1)(b-1) = 0 sampling is done by inversion if * either a * or b are not equal to one. If a = b = 1 a uniform random * * variate is delivered. * * * ***************************************************************** * * FUNCTION : - bsprc samples a random variate from the beta * * distribution with parameters a > 0, b > 0. * REFERENCES : - H. * Sakasegawa (1983): Stratified rejection and * squeeze method for * generating beta random * numbers, Ann. Inst. Statist. Math. 35 B, * * 291-302. * - H. Zechner, E. Stadlober (1993): Generating * beta * variates via patchwork rejection, * Computing 50, 1-18. * * * SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform generator with * * unsigned long integer *seed. * - b00(seed,a,b) ... Beta generator for * a<1, b<1 * - b01(seed,a,b) ... Beta generator for a<1<b or * b<1<a *
/** * Returns a beta distributed random number; bypasses the internal state. */ public double nextDouble(double alpha, double beta) { /*********************************************************************** * * Beta Distribution - Stratified Rejection/Patchwork Rejection * * * ***************************************************************** For * parameters a < 1 , b < 1 and a < 1 < b or b < 1 < a * the stratified * rejection methods b00 and b01 of Sakasegawa are * used. Both * procedures employ suitable two-part power functions * from which * samples can be obtained by inversion. * If a > 1 , b > 1 (unimodal * case) the patchwork rejection * method b1prs of Zechner/Stadlober is * utilized: * The area below the density function f(x) in its body is * * rearranged by certain point reflections. Within a large center * * interval variates are sampled efficiently by rejection from * uniform * hats. Rectangular immediate acceptance regions speed * up the * generation. The remaining tails are covered by * exponential * functions. * If (a-1)(b-1) = 0 sampling is done by inversion if * either a * or b are not equal to one. If a = b = 1 a uniform random * * variate is delivered. * * * ***************************************************************** * * FUNCTION : - bsprc samples a random variate from the beta * * distribution with parameters a > 0, b > 0. * REFERENCES : - H. * Sakasegawa (1983): Stratified rejection and * squeeze method for * generating beta random * numbers, Ann. Inst. Statist. Math. 35 B, * * 291-302. * - H. Zechner, E. Stadlober (1993): Generating * beta * variates via patchwork rejection, * Computing 50, 1-18. * * * SUBPROGRAMS: - drand(seed) ... (0,1)-Uniform generator with * * unsigned long integer *seed. * - b00(seed,a,b) ... Beta generator for * a<1, b<1 * - b01(seed,a,b) ... Beta generator for a<1<b or * b<1<a *