SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ConstantGen.java
1/*
2 * Class: ConstantGen
3 * Description: random variate generator for a constant 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 Éric Buist
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
38public class ConstantGen extends RandomVariateGen {
39 private double val;
40
44 public ConstantGen(double val) {
45 this.val = val;
46 }
47
48 @Override
49 public double nextDouble() {
50 return val;
51 }
52
53 @Override
54 public void nextArrayOfDouble(double[] v, int start, int n) {
55 for (int i = 0; i < n; i++)
56 v[start + i] = val;
57 }
58}
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
ConstantGen(double val)
Constructs a new constant generator returning the given value val.
void nextArrayOfDouble(double[] v, int start, int n)
Generates n random numbers from the continuous distribution contained in this object.