SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ErlangConvolutionGen.java
1/*
2 * Class: ErlangConvolutionGen
3 * Description: Erlang random variate generators using the convolution method
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
39public class ErlangConvolutionGen extends ErlangGen {
40
46 public ErlangConvolutionGen(RandomStream s, int k, double lambda) {
47 super(s, null);
48 setParams(k, lambda);
49 }
50
57 this(s, k, 1.0);
58 }
59
64 super(s, dist);
65 if (dist != null)
66 setParams(dist.getK(), dist.getLambda());
67 }
68
69 public double nextDouble() {
70 return convolution(stream, k, lambda);
71 }
72
73 public static double nextDouble(RandomStream s, int k, double lambda) {
74 return convolution(s, k, lambda);
75 }
76
77 private static double convolution(RandomStream s, int k, double lambda) {
78 double x = 0.0;
79 for (int i = 0; i < k; i++)
80 x += ExponentialDist.inverseF(lambda, s.nextDouble());
81 return x;
82 }
83}
Extends the class GammaDist for the special case of the Erlang distribution with shape parameter and...
Extends the class ContinuousDistribution for the exponential distribution tjoh95a  (page 494) with me...
double inverseF(double u)
Returns the inverse distribution function .
ErlangConvolutionGen(RandomStream s, int k, double lambda)
Creates an Erlang random variate generator with parameters k and.
ErlangConvolutionGen(RandomStream s, int k)
Creates an Erlang random variate generator with parameters k and.
ErlangConvolutionGen(RandomStream s, ErlangDist dist)
Creates a new generator for the distribution dist and stream s.
static double nextDouble(RandomStream s, int k, double lambda)
Generates a new variate from the Erlang distribution with parameters.
double nextDouble()
Generates a random number from the continuous distribution contained in 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.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...