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; } }

Ads help maintain this website.