SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
FoldedNormalGen.java
1/*
2 * Class: FoldedNormalGen
3 * Description: generator of random variates from the folded 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
45public class FoldedNormalGen extends RandomVariateGen {
46
47 // Distribution parameters
48 protected double mu;
49 protected double sigma;
50
55 public FoldedNormalGen(RandomStream s, double mu, double sigma) {
56 super(s, new FoldedNormalDist(mu, sigma));
57 setParams(mu, sigma);
58 }
59
64 super(s, dist);
65 if (dist != null)
66 setParams(dist.getMu(), dist.getSigma());
67 }
68
79 public static double nextDouble(RandomStream s, double mu, double sigma) {
80 return FoldedNormalDist.inverseF(mu, sigma, s.nextDouble());
81 }
82
88 public double getMu() {
89 return mu;
90 }
91
97 public double getSigma() {
98 return sigma;
99 }
100
101 protected void setParams(double mu, double sigma) {
102 if (sigma <= 0.0)
103 throw new IllegalArgumentException("sigma <= 0");
104 if (mu < 0.0)
105 throw new IllegalArgumentException("mu < 0");
106 this.mu = mu;
107 this.sigma = sigma;
108 }
109}
Extends the class ContinuousDistribution for the folded normal distribution with parameters and .
double inverseF(double u)
Returns the inverse distribution function .
double getSigma()
Returns the parameter of this object.
FoldedNormalGen(RandomStream s, double mu, double sigma)
Creates a new folded normal generator with parameters mu and sigma, using stream s.
static double nextDouble(RandomStream s, double mu, double sigma)
Generates a variate from the folded normal distribution with parameters &#160;mu and &#160;sigma,...
double getMu()
Returns the parameter of this object.
FoldedNormalGen(RandomStream s, FoldedNormalDist dist)
Creates a new generator for the distribution dist, using 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,...