SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
NormalGen.java
1/*
2 * Class: NormalGen
3 * Description: random variates generator from the normal 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
96public class NormalGen extends RandomVariateGen {
97 protected double mu;
98 protected double sigma = -1.0;
99
104 public NormalGen(RandomStream s, double mu, double sigma) {
105 super(s, new NormalDist(mu, sigma));
106 setParams(mu, sigma);
107 }
108
114 this(s, 0.0, 1.0);
115 }
116
122 super(s, dist);
123 if (dist != null)
124 setParams(dist.getMu(), dist.getSigma());
125 }
126
132 public static double nextDouble(RandomStream s, double mu, double sigma) {
133 return NormalDist.inverseF(mu, sigma, s.nextDouble());
134 }
135
139 public double getMu() {
140 return mu;
141 }
142
146 public double getSigma() {
147 return sigma;
148 }
149
153 protected void setParams(double mu, double sigma) {
154 if (sigma <= 0)
155 throw new IllegalArgumentException("sigma <= 0");
156 this.mu = mu;
157 this.sigma = sigma;
158 }
159}
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a  (page 80)).
double inverseF(double u)
Returns the inverse distribution function .
double getSigma()
Returns the parameter of this object.
double getMu()
Returns the parameter of this object.
void setParams(double mu, double sigma)
Sets the parameters and of this object.
static double nextDouble(RandomStream s, double mu, double sigma)
Generates a variate from the normal distribution with parameters.
NormalGen(RandomStream s)
Creates a standard normal random variate generator with mean 0 and standard deviation 1,...
NormalGen(RandomStream s, double mu, double sigma)
Creates a normal random variate generator with mean mu and standard deviation sigma,...
NormalGen(RandomStream s, NormalDist dist)
Creates a random variate generator for the normal distribution dist and 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,...