SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
NormalInverseGaussianIGGen.java
1/*
2 * Class: NormalInverseGaussianIGGen
3 * Description: normal inverse gaussian random variate generator
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 Richard Simard
9 * @since June 2008
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
53 private NormalGen genN;
54 private InverseGaussianGen genIG;
55
64 public NormalInverseGaussianIGGen(InverseGaussianGen ig, NormalGen ng, double beta, double mu) {
65 super(null, null);
66 setParams(ig, ng, beta, mu);
67 }
68
79 public static double nextDouble(InverseGaussianGen ig, NormalGen ng, double beta, double mu) {
80 return mynig(ig, ng, beta, mu);
81 }
82
83 public double nextDouble() {
84 return mynig(genIG, genN, beta, mu);
85 }
86
87// >>>>>>>>>>>>>>>>>>>> P R I V A T E M E T H O D S <<<<<<<<<<<<<<<<<<<
88
89 private static double mynig(InverseGaussianGen ig, NormalGen ng, double beta, double mu) {
90 double y = ig.nextDouble();
91 double x = mu + beta * y + Math.sqrt(y) * ng.nextDouble();
92 return x;
93 }
94
95 protected void setParams(InverseGaussianGen ig, NormalGen ng, double beta, double mu) {
96 delta = Math.sqrt(ig.getLambda());
97 gamma = delta / ig.getMu();
98 alpha = Math.sqrt(gamma * gamma + beta * beta);
99 setParams(alpha, beta, mu, delta);
100 this.genN = ng;
101 this.genIG = ig;
102 }
103}
This class implements random variate generators for the inverse Gaussian distribution with location p...
static double nextDouble(RandomStream s, double mu, double lambda)
Generates a variate from the inverse gaussian distribution with location parameter and scale paramet...
This class implements methods for generating random variates from the normal distribution .
static double nextDouble(RandomStream s, double mu, double sigma)
Generates a variate from the normal distribution with parameters.
NormalInverseGaussianGen(RandomStream s, double alpha, double beta, double mu, double delta)
Creates an normal inverse gaussian random variate generator with parameters = alpha,...
NormalInverseGaussianIGGen(InverseGaussianGen ig, NormalGen ng, double beta, double mu)
Creates a normal inverse gaussian random variate generator with parameters , = beta,...
double nextDouble()
Generates a random number from the continuous distribution contained in this object.
static double nextDouble(InverseGaussianGen ig, NormalGen ng, double beta, double mu)
Generates a new variate from the normal inverse gaussian distribution with parameters ,...