SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
BetaGen.java
1/*
2 * Class: BetaGen
3 * Description: random variate generators with the beta distribution
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.randvar;
26
27import umontreal.ssj.rng.*;
28import umontreal.ssj.probdist.*;
29
49public class BetaGen extends RandomVariateGen {
50
51 // Distribution parameters
52 protected double p;
53 protected double q;
54 protected double a;
55 protected double b;
56 protected int gen;
57
64 public BetaGen(RandomStream s, double alpha, double beta, double a, double b) {
65 super(s, new BetaDist(alpha, beta, a, b));
66 setParams(alpha, beta, a, b);
67 }
68
73 public BetaGen(RandomStream s, double alpha, double beta) {
74 this(s, alpha, beta, 0.0, 1.0);
75 }
76
80 public BetaGen(RandomStream s, BetaDist dist) {
81 super(s, dist);
82 if (dist != null)
83 setParams(dist.getAlpha(), dist.getBeta(), dist.getA(), dist.getB());
84 }
85
92 public static double nextDouble(RandomStream s, double alpha, double beta, double a, double b) {
93 return BetaDist.inverseF(alpha, beta, a, b, s.nextDouble());
94 }
95
99 public double getAlpha() {
100 return p;
101 }
102
106 public double getBeta() {
107 return q;
108 }
109
113 public double getA() {
114 return a;
115 }
116
120 public double getB() {
121 return b;
122 }
123
124 protected void setParams(double alpha, double beta, double aa, double bb) {
125 if (alpha <= 0.0)
126 throw new IllegalArgumentException("alpha <= 0");
127 if (beta <= 0.0)
128 throw new IllegalArgumentException("beta <= 0");
129 if (aa >= bb)
130 throw new IllegalArgumentException("a >= b");
131 p = alpha;
132 q = beta;
133 a = aa;
134 b = bb;
135 }
136}
Extends the class ContinuousDistribution for the beta distribution.
Definition BetaDist.java:54
double inverseF(double u)
Returns the inverse distribution function .
double getB()
Returns the parameter of this object.
Definition BetaGen.java:120
BetaGen(RandomStream s, double alpha, double beta, double a, double b)
Creates a new beta generator with parameters alpha and beta, over the interval.
Definition BetaGen.java:64
BetaGen(RandomStream s, double alpha, double beta)
Creates a new beta generator with parameters alpha and beta, over the interval ,...
Definition BetaGen.java:73
double getAlpha()
Returns the parameter of this object.
Definition BetaGen.java:99
double getBeta()
Returns the parameter of this object.
Definition BetaGen.java:106
double getA()
Returns the parameter of this object.
Definition BetaGen.java:113
static double nextDouble(RandomStream s, double alpha, double beta, double a, double b)
Generates a variate from the beta distribution with parameters.
Definition BetaGen.java:92
BetaGen(RandomStream s, BetaDist dist)
Creates a new generator for the distribution dist, using stream s.
Definition BetaGen.java:80
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...
double nextDouble()
Returns a (pseudo)random number from the uniform distribution over the interval , using this stream,...