26package umontreal.ssj.randvar;
28import umontreal.ssj.util.Num;
29import umontreal.ssj.rng.*;
30import umontreal.ssj.probdist.*;
47 private static final int bb = 0;
48 private static final int bc = 1;
70 setParams(alpha, beta, 0.0, 1.0);
81 this(s, s, alpha, beta);
95 setParams(alpha, beta, a, b);
106 this(s, s, alpha, beta, a, b);
119 setParams(dist.getAlpha(), dist.getBeta(), dist.getA(), dist.getB());
138 private void init() {
140 if (p > 1.0 && q > 1.0) {
142 am = (p < q) ? p : q;
143 bm = (p > q) ? p : q;
145 be = Math.sqrt((al - 2.0) / (2.0 * p * q - al));
149 am = (p > q) ? p : q;
150 bm = (p < q) ? p : q;
152 alnam = al * Math.log(al / am) - 1.386294361;
155 rk1 = si * (0.013888889 + 0.041666667 * bm) / (am * be - 0.77777778);
156 rk2 = 0.25 + (0.5 + 0.25 / si) * bm;
168 double u1, u2, v, w, y, z, r, s, t;
175 u1 = stream.nextDouble();
176 u2 = stream.nextDouble();
178 v = be * Math.log(u1 / (1.0 - u1));
179 w = am * Math.exp(v);
181 r = ga * v - 1.386294361;
185 if (s + 2.609437912 < 5.0 * z) {
190 if (r + al * Math.log(al / (bm + w)) < t)
195 X = equalsDouble(am, p) ? w / (bm + w) : bm / (bm + w);
203 u1 = stream.nextDouble();
204 u2 = stream.nextDouble();
212 if ((0.25 * u2 - y + z) >= rk1)
216 v = be * Math.log(u1 / (1.0 - u1));
218 if (alnam < Math.log(z))
220 X = equalsDouble(am, p) ? 1.0 : 0.0;
223 w = am * Math.exp(v);
224 if ((al * (Math.log(al / (bm + w)) + v) - 1.386294361) < Math.log(z))
228 X = !equalsDouble(am, p) ? bm / (bm + w) : w / (bm + w);
236 v = be * Math.log(u1 / (1.0 - u1));
238 X = equalsDouble(am, p) ? 1.0 : 0.0;
242 w = am * Math.exp(v);
243 X = !equalsDouble(am, p) ? bm / (bm + w) : w / (bm + w);
248 v = be * Math.log(u1 / (1.0 - u1));
250 if (alnam < Math.log(z))
252 X = equalsDouble(am, p) ? 1.0 : 0.0;
255 w = am * Math.exp(v);
256 if ((al * (Math.log(al / (bm + w)) + v) - 1.386294361) < Math.log(z))
260 X = !equalsDouble(am, p) ? bm / (bm + w) : w / (bm + w);
267 throw new IllegalStateException();
270 return a + (b - a) * X;
273 private static boolean equalsDouble(
double a,
double b) {
276 double absa = Math.abs(a);
277 double absb = Math.abs(b);
Extends the class ContinuousDistribution for the beta distribution.
BetaGen(RandomStream s, double alpha, double beta, double a, double b)
Creates a new beta generator with parameters alpha and beta, over the interval.
BetaRejectionLoglogisticGen(RandomStream s, double alpha, double beta)
Creates a beta random variate generator with parameters.
BetaRejectionLoglogisticGen(RandomStream s, RandomStream aux, double alpha, double beta, double a, double b)
Creates a beta random variate generator with parameters.
BetaRejectionLoglogisticGen(RandomStream s, double alpha, double beta, double a, double b)
Creates a beta random variate generator with parameters.
BetaRejectionLoglogisticGen(RandomStream s, RandomStream aux, double alpha, double beta)
Creates a beta random variate generator with parameters.
BetaRejectionLoglogisticGen(RandomStream s, BetaDist dist)
Same as BetaRejectionLoglogisticGen(s,s, dist).
BetaRejectionLoglogisticGen(RandomStream s, RandomStream aux, BetaDist dist)
Creates a new generator for the distribution dist, using stream s and auxiliary stream aux.
RandomStream getAuxStream()
Returns the auxiliary stream associated with that object.
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
This class provides various constants and methods to compute numerical quantities such as factorials,...
static final double DBL_EPSILON
Difference between 1.0 and the smallest double greater than 1.0.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...