SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
PoissonGen.java
1/*
2 * Class: PoissonGen
3 * Description: random variate generators having the Poisson 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.probdist.*;
28import umontreal.ssj.rng.*;
29
46public class PoissonGen extends RandomVariateGenInt {
47 protected double lambda;
48
54 public PoissonGen(RandomStream s, double lambda) {
55 super(s, new PoissonDist(lambda));
56 setParams(lambda);
57 }
58
64 super(s, dist);
65 if (dist != null)
66 setParams(dist.getLambda());
67 }
68
73 public static int nextInt(RandomStream s, double lambda) {
74 return PoissonDist.inverseF(lambda, s.nextDouble());
75 }
76
80 public double getLambda() {
81 return lambda;
82 }
83
87 protected void setParams(double lam) {
88 if (lam <= 0.0)
89 throw new IllegalArgumentException("lambda <= 0");
90 this.lambda = lam;
91 }
92}
Extends the class DiscreteDistributionInt for the Poisson distribution slaw00a  (page 325) with mean.
static int inverseF(double lambda, double u)
Performs a linear search to get the inverse function without precomputed tables.
double getLambda()
Returns the associated with this object.
PoissonGen(RandomStream s, double lambda)
Creates a Poisson random variate generator with parameter.
void setParams(double lam)
Sets the parameter lam of this object.
static int nextInt(RandomStream s, double lambda)
A static method for generating a random variate from a Poisson distribution with parameter = lambda.
PoissonGen(RandomStream s, PoissonDist dist)
Creates a new random variate generator using the Poisson distribution dist and stream s.
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,...