package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements random variate generators for the
* hyperbolic secant distribution with location
* parameter μ and scale parameter σ.
* The density function of this distribution is
*
*
*
* f (x) = 1/(2σ) sech(π/2(x - μ)/σ), - ∞ < x < ∞.
*
*
*/
public class HyperbolicSecantGen extends RandomVariateGen {
protected double mu;
protected double sigma;
/**
* Creates a hyperbolic secant random variate generator
* with parameters μ = mu and σ = sigma,
* using stream s.
*
*/
public HyperbolicSecantGen (RandomStream s, double mu, double sigma) {
super (s, new HyperbolicSecantDist(mu, sigma));
setParams (mu, sigma);
}
/**
* Creates a hyperbolic secant random variate generator
* with parameters μ = 0 and σ = 1,
* using stream s.
*
*/
public HyperbolicSecantGen (RandomStream s) {
this (s, 0.0, 1.0);
}
/**
* Creates a new generator for the distribution dist,
* using stream s.
*
*/
public HyperbolicSecantGen (RandomStream s, HyperbolicSecantDist dist) {
super (s, dist);
if (dist != null)
setParams (dist.getMu(), dist.getSigma());
}
/**
* Generates a variate from the hyperbolic secant distribution with
* location parameter μ and scale parameter σ.
*
*/
public static double nextDouble (RandomStream s, double mu, double sigma) {
return HyperbolicSecantDist.inverseF (mu, sigma, s.nextDouble());
}
/**
* Returns the parameter μ of this object.
*
*/
public double getMu() {
return mu;
}
/**
* Returns the parameter σ of this object.
*
*
*/
public double getSigma() {
return sigma;
}
/**
* Sets the parameters μ and σ of this object.
*
*/
protected void setParams (double mu, double sigma) {
if (sigma <= 0.0)
throw new IllegalArgumentException ("sigma <= 0");
this.mu = mu;
this.sigma = sigma;
}
}
Ads help maintain this website.