SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ErlangGen.java
1/*
2 * Class: ErlangGen
3 * Description: random variate generators for the Erlang 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
44public class ErlangGen extends GammaGen {
45 protected int k = -1;
46
52 public ErlangGen(RandomStream s, int k, double lambda) {
53 super(s, new ErlangDist(k, lambda));
54 setParams(k, lambda);
55 }
56
62 public ErlangGen(RandomStream s, int k) {
63 this(s, k, 1.0);
64 }
65
70 super(s, dist);
71 if (dist != null)
72 setParams(dist.getK(), dist.getLambda());
73 }
74
80 public static double nextDouble(RandomStream s, int k, double lambda) {
81 return ErlangDist.inverseF(k, lambda, 15, s.nextDouble());
82 }
83
87 public int getK() {
88 return k;
89 }
90
94 protected void setParams(int k, double lambda) {
95 if (lambda <= 0.0)
96 throw new IllegalArgumentException("lambda <= 0");
97 if (k <= 0)
98 throw new IllegalArgumentException("k <= 0");
99 this.lambda = lambda;
100 this.k = k;
101 }
102}
Extends the class GammaDist for the special case of the Erlang distribution with shape parameter and...
static double inverseF(int k, double lambda, int d, double u)
Returns the inverse distribution function.
ErlangGen(RandomStream s, int k)
Creates an Erlang random variate generator with parameters k and.
ErlangGen(RandomStream s, ErlangDist dist)
Creates a new generator for the distribution dist and stream s.
int getK()
Returns the parameter of this object.
void setParams(int k, double lambda)
Sets the parameter and of this object.
ErlangGen(RandomStream s, int k, double lambda)
Creates an Erlang random variate generator with parameters k and.
static double nextDouble(RandomStream s, int k, double lambda)
Generates a new variate from the Erlang distribution with parameters.
GammaGen(RandomStream s, double alpha, double lambda)
Creates a gamma random variate generator with parameters.
Definition GammaGen.java:56
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,...