SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
HalfNormalGen.java
1/*
2 * Class: HalfNormalGen
3 * Description: generator of random variates from the half-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
42public class HalfNormalGen extends RandomVariateGen {
43
44 // Distribution parameters
45 protected double mu;
46 protected double sigma;
47
52 public HalfNormalGen(RandomStream s, double mu, double sigma) {
53 super(s, new HalfNormalDist(mu, sigma));
54 setParams(mu, sigma);
55 }
56
61 super(s, dist);
62 if (dist != null)
63 setParams(dist.getMu(), dist.getSigma());
64 }
65
76 public static double nextDouble(RandomStream s, double mu, double sigma) {
77 return HalfNormalDist.inverseF(mu, sigma, s.nextDouble());
78 }
79
85 public double getMu() {
86 return mu;
87 }
88
94 public double getSigma() {
95 return sigma;
96 }
97
98 protected void setParams(double mu, double sigma) {
99 if (sigma <= 0.0)
100 throw new IllegalArgumentException("sigma <= 0");
101 this.mu = mu;
102 this.sigma = sigma;
103 }
104}
Extends the class ContinuousDistribution for the half-normal distribution with parameters and .
double inverseF(double u)
Returns the inverse distribution function .
HalfNormalGen(RandomStream s, double mu, double sigma)
Creates a new half-normal generator with parameters mu and sigma, using stream s.
HalfNormalGen(RandomStream s, HalfNormalDist dist)
Creates a new generator for the distribution dist, using stream s.
static double nextDouble(RandomStream s, double mu, double sigma)
Generates a variate from the half-normal distribution with parameters &#160;mu and &#160;sigma,...
double getMu()
Returns the parameter of this object.
double getSigma()
Returns the parameter of this object.
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,...