SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ChiSquareNoncentralGamGen.java
1/*
2 * Class: ChiSquareNoncentralGamGen
3 * Description: noncentral chi-square random variate generators using the
4 additive property of the noncentral chi-square distribution
5 * Environment: Java
6 * Software: SSJ
7 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
8 * Organization: DIRO, Universite de Montreal
9 * @author Richard Simard
10 * @since
11 *
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 *
25 */
26package umontreal.ssj.randvar;
27
28import umontreal.ssj.rng.*;
29
58 private double racLam = -1.0;
59
66 public ChiSquareNoncentralGamGen(RandomStream stream, double nu, double lambda) {
67 super(stream, null);
68 setParams(nu, lambda);
69 racLam = Math.sqrt(lambda);
70 }
71
72 public double nextDouble() {
73 return gamGen(stream, nu, racLam);
74 }
75
81 public static double nextDouble(RandomStream stream, double nu, double lambda) {
82 double racLam = Math.sqrt(lambda);
83 return gamGen(stream, nu, racLam);
84 }
85
86//>>>>>>>>>>>>>>>>>>>> P R I V A T E M E T H O D S <<<<<<<<<<<<<<<<<<<<
87
88 private static double gamGen(RandomStream s, double nu, double racLam) {
89 // racLam = sqrt(lambda)
90 double x = NormalACRGen.nextDouble(s, racLam, 1.0);
91 double y = GammaAcceptanceRejectionGen.nextDouble(s, 0.5 * (nu - 1.0), 0.5);
92 return x * x + y;
93 }
94
95}
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
static double nextDouble(RandomStream stream, double nu, double lambda)
Generates a variate from the noncentral chi square distribution with parameters &#160;nu and &#160;lambda usi...
ChiSquareNoncentralGamGen(RandomStream stream, double nu, double lambda)
Creates a noncentral chi square random variate generator with with.
void setParams(double nu, double lambda)
Sets the parameters nu and lambda of this object.
ChiSquareNoncentralGen(RandomStream s, double nu, double lambda)
Creates a noncentral chi square random variate generator with nu.
This class implements gamma random variate generators using a method that combines acceptance-rejecti...
static double nextDouble(RandomStream s, RandomStream aux, double alpha, double lambda)
Generates a new gamma variate with parameters &#160;alpha and &#160;lambda, using main stream s and auxilia...
This class implements normal random variate generators using the acceptance-complement ratio method r...
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...