SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ChiSquareGen.java
1/*
2 * Class: ChiSquareGen
3 * Description: random variate generators with the chi square 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
46public class ChiSquareGen extends RandomVariateGen {
47 protected int n = -1;
48
53 public ChiSquareGen(RandomStream s, int n) {
54 super(s, new ChiSquareDist(n));
55 setParams(n);
56 }
57
62 super(s, dist);
63 if (dist != null)
64 setParams(dist.getN());
65 }
66
72 public static double nextDouble(RandomStream s, int n) {
73 return ChiSquareDist.inverseF(n, s.nextDouble());
74 }
75
79 public int getN() {
80 return n;
81 }
82
83 protected void setParams(int n) {
84 if (n <= 0)
85 throw new IllegalArgumentException("n <= 0");
86 this.n = n;
87 }
88}
Extends the class ContinuousDistribution for the chi-square distribution with degrees of freedom,...
double inverseF(double u)
Returns the inverse distribution function .
ChiSquareGen(RandomStream s, ChiSquareDist dist)
Create a new generator for the distribution dist and stream s.
int getN()
Returns the value of for this object.
static double nextDouble(RandomStream s, int n)
Generates a new variate from the chi square distribution with.
ChiSquareGen(RandomStream s, int n)
Creates a chi square random variate generator with degrees of freedom, using 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,...