package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;


/**
 * This class implements random variate generators for the
 * Rayleigh distribution.
 *  Its density is
 * 
*
* * * * * * * * * * *
f (x)=(x-a) e-(x-a)2/(2β2)/β2        for x >= a *  
f (x)=0        for x < a, *  
*
* * where β > 0. * */ public class RayleighGen extends RandomVariateGen { private double a; private double beta; /** * Creates a Rayleigh random variate generator with parameters * a = a and β = beta, using stream s. * */ public RayleighGen (RandomStream s, double a, double beta) { super (s, new RayleighDist(a, beta)); setParams (a, beta); } /** * Creates a Rayleigh random variate generator with parameters * a = 0 and β = beta, using stream s. * */ public RayleighGen (RandomStream s, double beta) { this (s, 0.0, beta); } /** * Creates a new generator for the Rayleigh distribution dist * and stream s. * */ public RayleighGen (RandomStream s, RayleighDist dist) { super (s, dist); if (dist != null) setParams (dist.getA(), dist.getSigma()); } /** * Uses inversion to generate a new variate from the Rayleigh * distribution with parameters a = a and * β = beta, using stream s. * */ public static double nextDouble (RandomStream s, double a, double beta) { return RayleighDist.inverseF (a, beta, s.nextDouble()); } /** * Returns the parameter a. * */ public double getA() { return a; } /** * Returns the parameter β. * */ public double getSigma() { return beta; } /** * Sets the parameters a = a and β = beta * for this object. * */ public void setParams (double a, double beta) { if (beta <= 0.0) throw new IllegalArgumentException ("beta <= 0"); this.a = a; this.beta = beta; } }

Ads help maintain this website.