SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
UniformGen.java
1/*
2 * Class: UniformGen
3 * Description: random variate generators for the uniform distribution over the reals
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
43public class UniformGen extends RandomVariateGen {
44 private double a;
45 private double b;
46
52 public UniformGen(RandomStream s, double a, double b) {
53 super(s, new UniformDist(a, b));
54 setParams(a, b);
55 }
56
62 this(s, 0.0, 1.0);
63 }
64
69 super(s, dist);
70 if (dist != null)
71 setParams(dist.getA(), dist.getB());
72 }
73
79 static public double nextDouble(RandomStream s, double a, double b) {
80 return UniformDist.inverseF(a, b, s.nextDouble());
81 }
82
86 public double getA() {
87 return a;
88 }
89
93 public double getB() {
94 return b;
95 }
96
100 private void setParams(double a, double b) {
101 if (b <= a)
102 throw new IllegalArgumentException("b <= a");
103 this.a = a;
104 this.b = b;
105 }
106}
Extends the class ContinuousDistribution for the uniform distribution tjoh95b  (page 276) over the in...
double inverseF(double u)
Returns the inverse distribution function .
static double nextDouble(RandomStream s, double a, double b)
Generates a uniform random variate over the interval.
UniformGen(RandomStream s)
Creates a uniform random variate generator over the interval , using stream s.
UniformGen(RandomStream s, UniformDist dist)
Creates a new generator for the uniform distribution dist and stream s.
UniformGen(RandomStream s, double a, double b)
Creates a uniform random variate generator over the interval.
double getA()
Returns the value of for this object.
double getB()
Returns the value of for this object.
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,...