umontreal.iro.lecuyer.randvar.LoglogisticGen 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: LoglogisticGen
* Description: random variate generators for the log-logistic 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
* log-logistic distribution with shape parameter
* α > 0
* and scale parameter β > 0.
* The density function of this distribution is
*
*
*
* f (x) = (α(x/β)α-1)/(β[1 + (x/β)α]2) for x > 0.
*
*
*/
public class LoglogisticGen extends RandomVariateGen {
protected double alpha;
protected double beta;
/**
* Creates a log-logistic random variate generator with parameters
* α = alpha and β = beta, using stream s.
*
*/
public LoglogisticGen (RandomStream s, double alpha, double beta) {
super (s, new LoglogisticDist(alpha, beta));
setParams (alpha, beta);
}
/**
* Creates a new generator for the distribution dist,
* using stream s.
*
*/
public LoglogisticGen (RandomStream s, LoglogisticDist dist) {
super (s, dist);
if (dist != null)
setParams (dist.getAlpha(), dist.getBeta());
}
/**
* Generates a variate from the log-logistic distribution
* with shape parameter
* α > 0 and scale parameter β > 0.
*
*/
public static double nextDouble (RandomStream s,
double alpha, double beta) {
return LoglogisticDist.inverseF (alpha, beta, s.nextDouble());
}
/**
* Returns the parameter α of this object.
*
*/
public double getAlpha() {
return alpha;
}
/**
* Returns the parameter β of this object.
*
*/
public double getBeta() {
return beta;
}
protected void setParams (double alpha, double beta) {
if (alpha <= 0.0)
throw new IllegalArgumentException ("alpha <= 0");
if (beta <= 0.0)
throw new IllegalArgumentException ("beta <= 0");
this.alpha = alpha;
this.beta = beta;
}
}