SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
GammaGen.java
1/*
2 * Class: GammaGen
3 * Description: random variate generators for the gamma 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
47public class GammaGen extends RandomVariateGen {
48 protected double alpha = -1.0;
49 protected double lambda = -1.0;
50
56 public GammaGen(RandomStream s, double alpha, double lambda) {
57 super(s, new GammaDist(alpha, lambda));
58 setParams(alpha, lambda);
59 }
60
66 public GammaGen(RandomStream s, double alpha) {
67 this(s, alpha, 1.0);
68 }
69
75 super(s, dist);
76 if (dist != null)
77 setParams(dist.getAlpha(), dist.getLambda());
78 }
79
85 public static double nextDouble(RandomStream s, double alpha, double lambda) {
86 return GammaDist.inverseF(alpha, lambda, 15, s.nextDouble());
87 }
88
92 public double getAlpha() {
93 return alpha;
94 }
95
99 public double getLambda() {
100 return lambda;
101 }
102
106 protected void setParams(double alpha, double lambda) {
107 if (lambda <= 0.0)
108 throw new IllegalArgumentException("lambda <= 0");
109 if (alpha <= 0.0)
110 throw new IllegalArgumentException("alpha <= 0");
111 this.lambda = lambda;
112 this.alpha = alpha;
113 }
114}
Extends the class ContinuousDistribution for the gamma distribution tjoh95a  (page 337) with shape pa...
double inverseF(double u)
Returns the inverse distribution function .
GammaGen(RandomStream s, double alpha, double lambda)
Creates a gamma random variate generator with parameters.
Definition GammaGen.java:56
double getLambda()
Returns the parameter of this object.
Definition GammaGen.java:99
void setParams(double alpha, double lambda)
Sets the parameter and of this object.
double getAlpha()
Returns the parameter of this object.
Definition GammaGen.java:92
GammaGen(RandomStream s, GammaDist dist)
Creates a new generator object for the gamma distribution dist and stream s.
Definition GammaGen.java:74
static double nextDouble(RandomStream s, double alpha, double lambda)
Generates a new gamma random variate with parameters &#160;alpha and &#160;lambda, using stream s.
Definition GammaGen.java:85
GammaGen(RandomStream s, double alpha)
Creates a gamma random variate generator with parameters.
Definition GammaGen.java:66
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,...