umontreal.iro.lecuyer.randvar.PowerGen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ssj Show documentation
Show all versions of ssj Show documentation
SSJ is a Java library for stochastic simulation, developed under the direction of Pierre L'Ecuyer,
in the Département d'Informatique et de Recherche Opérationnelle (DIRO), at the Université de Montréal.
It provides facilities for generating uniform and nonuniform random variates, computing different
measures related to probability distributions, performing goodness-of-fit tests, applying quasi-Monte
Carlo methods, collecting (elementary) statistics, and programming discrete-event simulations with both
events and processes.
The newest version!
/*
* Class: PowerGen
* Description: random variate generators for the power distribution
* Environment: Java
* Software: SSJ
* Copyright (C) 2001 Pierre L'Ecuyer and Université de Montréal
* Organization: DIRO, Université de Montréal
* @author
* @since
* SSJ is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License (GPL) as published by the
* Free Software Foundation, either version 3 of the License, or
* any later version.
* SSJ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* A copy of the GNU General Public License is available at
GPL licence site.
*/
package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements random variate generators for the
* power distribution with shape parameter
* c > 0, over the interval [a, b].
* Its density is
*
*
*
* f (x) = c(x - a)c-1/(b - a)c
*
* for
* a <= x <= b, and 0 elsewhere.
*
*/
public class PowerGen extends RandomVariateGen {
private double a;
private double b;
private double c;
/**
* Creates a Power random variate generator with parameters
* a = a, b = b and c = c,
* using stream s.
*
*/
public PowerGen (RandomStream s, double a, double b, double c) {
super (s, new PowerDist(a, b, c));
setParams (a, b, c);
}
/**
* Creates a Power random variate generator with parameters
* a = 0, b = 1 and c = c, using stream s.
*
*/
public PowerGen (RandomStream s, double c) {
super (s, new PowerDist(0.0, 1.0, c));
setParams (0.0, 1.0, c);
}
/**
* Creates a new generator for the power distribution dist
* and stream s.
*
*/
public PowerGen (RandomStream s, PowerDist dist) {
super (s, dist);
if (dist != null)
setParams (dist.getA(), dist.getB(), dist.getC());
}
/**
* Uses inversion to generate a new variate from the power
* distribution with parameters a = a, b = b, and
* c = c, using stream s.
*
*/
public static double nextDouble (RandomStream s, double a, double b,
double c) {
return PowerDist.inverseF (a, b, c, s.nextDouble());
}
/**
* Returns the parameter a.
*
*/
public double getA() {
return a;
}
/**
* Returns the parameter b.
*
*/
public double getB() {
return b;
}
/**
* Returns the parameter c.
*
*/
public double getC() {
return c;
}
/**
* Sets the parameters a, b and c for this object.
*
*
*/
public void setParams (double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
}