SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
StudentNoncentralGen.java
1/*
2 * Class: StudentNoncentralGen
3 * Description: random variate generator for the noncentral Student-t 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 StudentNoncentralGen extends RandomVariateGen {
47 private NormalGen normgen;
48 private ChiSquareGen chigen;
49 private int n; // degrees of freedom of chi-square
50
51 public double nextDouble() {
52 double x = normgen.nextDouble();
53 double y = chigen.nextDouble();
54 return x / Math.sqrt(y / n);
55 }
56
62 super(null, null);
63 setNormalGen(ngen);
64 setChiSquareGen(cgen);
65 }
66
70 public void setNormalGen(NormalGen ngen) {
71 if (1.0 != ngen.getSigma())
72 throw new IllegalArgumentException(" variance of normal must be 1");
73 normgen = ngen;
74 }
75
79 public void setChiSquareGen(ChiSquareGen cgen) {
80 chigen = cgen;
81 n = cgen.getN();
82 }
83
84}
This class implements random variate generators with the chi square distribution with degrees of fre...
int getN()
Returns the value of for this object.
This class implements methods for generating random variates from the normal distribution .
double getSigma()
Returns the parameter of this object.
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
void setNormalGen(NormalGen ngen)
Sets the normal generator to ngen.
void setChiSquareGen(ChiSquareGen cgen)
Sets the chi-square generator to cgen.
StudentNoncentralGen(NormalGen ngen, ChiSquareGen cgen)
Creates a noncentral-t random variate generator using normal generator ngen and chi-square generator ...