SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
InverseGammaGen.java
1/*
2 * Class: InverseGammaGen
3 * Description: random variate generators for the inverse 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
45public class InverseGammaGen extends RandomVariateGen {
46 protected double alpha;
47 protected double beta;
48
54 public InverseGammaGen(RandomStream s, double alpha, double beta) {
55 super(s, new InverseGammaDist(alpha, beta));
56 setParams(alpha, beta);
57 }
58
64 public InverseGammaGen(RandomStream s, double alpha) {
65 this(s, alpha, 1.0);
66 }
67
72 super(s, dist);
73 if (dist != null)
74 setParams(dist.getAlpha(), dist.getBeta());
75 }
76
81 public static double nextDouble(RandomStream s, double alpha, double beta) {
82 return InverseGammaDist.inverseF(alpha, beta, s.nextDouble());
83 }
84
88 public double getAlpha() {
89 return alpha;
90 }
91
95 public double getBeta() {
96 return beta;
97 }
98
99 protected void setParams(double alpha, double beta) {
100 if (alpha <= 0.0)
101 throw new IllegalArgumentException("alpha <= 0");
102 if (beta <= 0.0)
103 throw new IllegalArgumentException("beta <= 0");
104 this.alpha = alpha;
105 this.beta = beta;
106 }
107}
Extends the class ContinuousDistribution for the inverse gamma distribution with shape parameter and...
double inverseF(double u)
Returns the inverse distribution function .
double getAlpha()
Returns the parameter of this object.
InverseGammaGen(RandomStream s, double alpha, double beta)
Creates an inverse gamma random variate generator with parameters.
static double nextDouble(RandomStream s, double alpha, double beta)
Generates a variate from the inverse gamma distribution with shape parameter and scale parameter .
InverseGammaGen(RandomStream s, InverseGammaDist dist)
Creates a new generator for the distribution dist, using stream s.
double getBeta()
Returns the parameter of this object.
InverseGammaGen(RandomStream s, double alpha)
Creates an inverse gamma random variate generator with parameters.
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,...