package umontreal.iro.lecuyer.randvar;
import umontreal.iro.lecuyer.rng.*;
import umontreal.iro.lecuyer.probdist.*;
/**
* This class implements random variate generators for the
* logistic distribution. Its parameters are α and
* λ > 0.
* Its density function is
*
*
*
* f (x) = λe-λ(x-α)/[(1 + e-λ(x-α))2] for - ∞ < x < ∞.
*
* The (non-static) nextDouble method simply calls inverseF on the
* distribution.
*
*/
public class LogisticGen extends RandomVariateGen {
protected double alpha = -1.0;
protected double lambda = -1.0;
/**
* Creates a logistic random variate generator with parameters
* α = alpha and λ = lambda,
* using stream s.
*
*/
public LogisticGen (RandomStream s, double alpha, double lambda) {
super (s, new LogisticDist(alpha, lambda));
setParams (alpha, lambda);
}
/**
* Creates a logistic random variate generator with parameters
*
* α = 0 and
* λ = 1,
* using stream s.
*
*/
public LogisticGen (RandomStream s) {
this (s, 0.0, 1.0);
}
/**
* Creates a new generator for the logistic distribution
* dist and stream s.
*
*/
public LogisticGen (RandomStream s, LogisticDist dist) {
super (s, dist);
if (dist != null)
setParams (dist.getAlpha(), dist.getLambda());
}
/**
* Generates a new variate from the logistic distribution
* with parameters α = alpha and λ = lambda,
* using stream s.
*
*/
public static double nextDouble (RandomStream s,
double alpha, double lambda) {
return LogisticDist.inverseF (alpha, lambda, s.nextDouble());
}
/**
* Returns the parameter α of this object.
*
*/
public double getAlpha() {
return alpha;
}
/**
* Returns the parameter λ of this object.
*
*
*/
public double getLambda() {
return lambda;
}
/**
* Sets the parameter α and λ of this object.
*
*/
protected void setParams (double alpha, double lambda) {
if (lambda <= 0.0)
throw new IllegalArgumentException ("lambda <= 0");
this.lambda = lambda;
this.alpha = alpha;
}
}
Ads help maintain this website.