SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
LaplaceGen.java
1/*
2 * Class: LaplaceGen
3 * Description: generator of random variates from the Laplace 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 LaplaceGen extends RandomVariateGen {
46 private double mu;
47 private double beta;
48
54 public LaplaceGen(RandomStream s, double mu, double beta) {
55 super(s, new LaplaceDist(mu, beta));
56 setParams(mu, beta);
57 }
58
64 this(s, 0.0, 1.0);
65 }
66
71 super(s, dist);
72 if (dist != null)
73 setParams(dist.getMu(), dist.getBeta());
74 }
75
81 public static double nextDouble(RandomStream s, double mu, double beta) {
82 return LaplaceDist.inverseF(mu, beta, s.nextDouble());
83 }
84
88 public double getMu() {
89 return mu;
90 }
91
95 public double getBeta() {
96 return beta;
97 }
98
102 protected void setParams(double mu, double beta) {
103 if (beta <= 0.0)
104 throw new IllegalArgumentException("beta <= 0");
105 this.mu = mu;
106 this.beta = beta;
107 }
108}
Extends the class ContinuousDistribution for the Laplace distribution (see, e.g., tjoh95b  (page 165)...
double inverseF(double u)
Returns the inverse distribution function .
LaplaceGen(RandomStream s)
Creates a Laplace random variate generator with parameters and , using stream s.
double getBeta()
Returns the parameter .
static double nextDouble(RandomStream s, double mu, double beta)
Generates a new variate from the Laplace distribution with parameters &#160;mu and &#160;beta,...
LaplaceGen(RandomStream s, double mu, double beta)
Creates a Laplace random variate generator with parameters.
LaplaceGen(RandomStream s, LaplaceDist dist)
Creates a new generator for the Laplace distribution dist and stream s.
void setParams(double mu, double beta)
Sets the parameters and of this object.
double getMu()
Returns the parameter .
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,...