SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ChiGen.java
1/*
2 * Class: ChiGen
3 * Description: random variate generators for the chi 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
47public class ChiGen extends RandomVariateGen {
48 protected int nu = -1;
49
54 public ChiGen(RandomStream s, int nu) {
55 super(s, new ChiDist(nu));
56 setParams(nu);
57 }
58
62 public ChiGen(RandomStream s, ChiDist dist) {
63 super(s, dist);
64 if (dist != null)
65 setParams(dist.getNu());
66 }
67
73 public static double nextDouble(RandomStream s, int nu) {
74 if (nu <= 0)
75 throw new IllegalArgumentException("nu <= 0");
76 return ChiDist.inverseF(nu, s.nextDouble());
77 }
78
82 public int getNu() {
83 return nu;
84 }
85
86 protected void setParams(int nu) {
87 if (nu <= 0)
88 throw new IllegalArgumentException("nu <= 0");
89 this.nu = nu;
90 }
91}
Extends the class ContinuousDistribution for the chi distribution.
Definition ChiDist.java:49
double inverseF(double u)
Returns the inverse distribution function .
Definition ChiDist.java:90
static double nextDouble(RandomStream s, int nu)
Generates a random variate from the chi distribution with &#160;nu degrees of freedom,...
Definition ChiGen.java:73
ChiGen(RandomStream s, int nu)
Creates a chi random variate generator with nu degrees of freedom, using stream s.
Definition ChiGen.java:54
int getNu()
Returns the value of for this object.
Definition ChiGen.java:82
ChiGen(RandomStream s, ChiDist dist)
Create a new generator for the distribution dist, using stream s.
Definition ChiGen.java:62
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,...