SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
InverseFromDensityGen.java
1/*
2 * Class: InverseFromDensityGen
3 * Description: generator of random variates by numerical inversion of
4 an arbitrary continuous distribution when only the
5 probability density is known
6 * Environment: Java
7 * Software: SSJ
8 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
9 * Organization: DIRO, Universite de Montreal
10 * @author Richard Simard
11 * @since June 2008
12 *
13 *
14 * Licensed under the Apache License, Version 2.0 (the "License");
15 * you may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
17 *
18 * http://www.apache.org/licenses/LICENSE-2.0
19 *
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 *
26 */
27package umontreal.ssj.randvar;
28
29import umontreal.ssj.functions.MathFunction;
30import umontreal.ssj.rng.RandomStream;
31import umontreal.ssj.probdist.ContinuousDistribution;
32import umontreal.ssj.probdist.InverseDistFromDensity;
33
242public class InverseFromDensityGen extends RandomVariateGen {
243
261 public InverseFromDensityGen(RandomStream stream, ContinuousDistribution dis, double xc, double eps, int order) {
262 super(stream, null);
263 dist = new InverseDistFromDensity(dis, xc, eps, order);
264 }
265
272 public InverseFromDensityGen(RandomStream stream, MathFunction dens, double xc, double eps, int order, double xleft,
273 double xright) {
274 super(stream, null);
275 dist = new InverseDistFromDensity(dens, xc, eps, order, xleft, xright);
276 }
277
281 public double nextDouble() {
282 return dist.inverseF(stream.nextDouble());
283 }
284
288 public double getXc() {
289 return ((InverseDistFromDensity) dist).getXc();
290 }
291
295 public double getEpsilon() {
296 return ((InverseDistFromDensity) dist).getEpsilon();
297 }
298
302 public int getOrder() {
303 return ((InverseDistFromDensity) dist).getOrder();
304 }
305}
Classes implementing continuous distributions should inherit from this base class.
Implements a method for computing the inverse of an arbitrary continuous distribution function when o...
InverseFromDensityGen(RandomStream stream, ContinuousDistribution dis, double xc, double eps, int order)
Creates a new generator for the continuous distribution dis, using stream stream.
int getOrder()
Returns the order of the interpolating polynomial.
double nextDouble()
Generates a new random variate.
InverseFromDensityGen(RandomStream stream, MathFunction dens, double xc, double eps, int order, double xleft, double xright)
Creates a new generator from the continuous probability density dens.
double getEpsilon()
Returns the -resolution eps.
double getXc()
Returns the xc given in the constructor.
This interface should be implemented by classes which represent univariate mathematical functions.
This interface defines the basic structures to handle multiple streams of uniform (pseudo)random numb...