SSJ
V. 2.6.

umontreal.iro.lecuyer.probdist
Class HypoExponentialDistQuick

java.lang.Object
  extended by umontreal.iro.lecuyer.probdist.ContinuousDistribution
      extended by umontreal.iro.lecuyer.probdist.HypoExponentialDist
          extended by umontreal.iro.lecuyer.probdist.HypoExponentialDistQuick
All Implemented Interfaces:
Distribution

public class HypoExponentialDistQuick
extends HypoExponentialDist

This class is a subclass of HypoExponentialDist and also implements the hypoexponential distribution. It uses different algorithms to compute the probabilities. The formula for the complementary distribution is mathematically equivalent to (see and)

bar(F)(x) = P[X1 + ... + Xk > x] = ∑i=1ke-λixj=1,  j≠ikλj/(λj-λi).

The expression is much faster to compute than the matrix exponential formula, but it becomes numerically unstable when k gets large and/or the differences between the λi are too small, because it is an alternating sum with relatively large terms of similar size. When the λi are close, many of the factors λj - λi in are small, and the effect of this is amplified when k is large. This gives rise to large terms of opposite sign in the sum and the formula becomes unstable due to subtractive cancellation. For example, with the computations done in standard 64-bit floating-point arithmetic, if the λi are regularly spaced with differences of λi+1 - λi = 0.1 for all i, the formula breaks down already for k =  15, while if the differences λi+1 - λi = 3, it gives a few decimal digits of precision for k up to  =  300.

The formula for the density is mathematically equivalent to the much faster formula

f (x) = ∑i=1kλie-λixj=1,  j≠ikλj/(λj-λi),

which is also numerically unstable when k gets large and/or the differences between the λi are too small.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
decPrec
 
Constructor Summary
HypoExponentialDistQuick(double[] lambda)
          Constructs a HypoExponentialDistQuick object, with rates λi = lambda[i - 1], i = 1,…, k.
 
Method Summary
 double barF(double x)
          Returns the complementary distribution function.
static double barF(double[] lambda, double x)
          Computes the complementary distribution bar(F)(x), with λi = lambda[i - 1], i = 1,…, k.
 double cdf(double x)
          Returns the distribution function F(x).
static double cdf(double[] lambda, double x)
          Computes the distribution function F(x), with λi = lambda[i - 1], i = 1,…, k.
 double density(double x)
          Returns f (x), the density evaluated at x.
static double density(double[] lambda, double x)
          Computes the density function f (x), with λi = lambda[i - 1], i = 1,…, k.
 double inverseF(double u)
          Returns the inverse distribution function x = F-1(u).
static double inverseF(double[] lambda, double u)
          Computes the inverse distribution function F-1(u), with λi = lambda[i - 1], i = 1,…, k.
 void setLambda(double[] lambda)
          Sets the values λi =lambda[i - 1], i = 1,…, k for this object.
 String toString()
           
 
Methods inherited from class umontreal.iro.lecuyer.probdist.HypoExponentialDist
cdf2, getLambda, getMean, getMean, getParams, getStandardDeviation, getStandardDeviation, getVariance, getVariance
 
Methods inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
getXinf, getXsup, inverseBisection, inverseBrent, setXinf, setXsup
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HypoExponentialDistQuick

public HypoExponentialDistQuick(double[] lambda)
Constructs a HypoExponentialDistQuick object, with rates λi = lambda[i - 1], i = 1,…, k.

Parameters:
lambda - rates of the hypoexponential distribution
Method Detail

density

public double density(double x)
Description copied from class: ContinuousDistribution
Returns f (x), the density evaluated at x.

Overrides:
density in class HypoExponentialDist
Parameters:
x - value at which the density is evaluated
Returns:
density function evaluated at x

cdf

public double cdf(double x)
Description copied from interface: Distribution
Returns the distribution function F(x).

Specified by:
cdf in interface Distribution
Overrides:
cdf in class HypoExponentialDist
Parameters:
x - value at which the distribution function is evaluated
Returns:
distribution function evaluated at x

barF

public double barF(double x)
Description copied from class: ContinuousDistribution
Returns the complementary distribution function. The default implementation computes bar(F)(x) = 1 - F(x).

Specified by:
barF in interface Distribution
Overrides:
barF in class HypoExponentialDist
Parameters:
x - value at which the complementary distribution function is evaluated
Returns:
complementary distribution function evaluated at x

inverseF

public double inverseF(double u)
Description copied from class: ContinuousDistribution
Returns the inverse distribution function x = F-1(u). Restrictions: u∈[0, 1].

Specified by:
inverseF in interface Distribution
Overrides:
inverseF in class HypoExponentialDist
Parameters:
u - value at which the inverse distribution function is evaluated
Returns:
the inverse distribution function evaluated at u

density

public static double density(double[] lambda,
                             double x)
Computes the density function f (x), with λi = lambda[i - 1], i = 1,…, k.

Parameters:
lambda - rates of the hypoexponential distribution
x - value at which the density is evaluated
Returns:
density at x

cdf

public static double cdf(double[] lambda,
                         double x)
Computes the distribution function F(x), with λi = lambda[i - 1], i = 1,…, k.

Parameters:
lambda - rates of the hypoexponential distribution
x - value at which the distribution is evaluated
Returns:
value of distribution at x

barF

public static double barF(double[] lambda,
                          double x)
Computes the complementary distribution bar(F)(x), with λi = lambda[i - 1], i = 1,…, k.

Parameters:
lambda - rates of the hypoexponential distribution
x - value at which the complementary distribution is evaluated
Returns:
value of complementary distribution at x

inverseF

public static double inverseF(double[] lambda,
                              double u)
Computes the inverse distribution function F-1(u), with λi = lambda[i - 1], i = 1,…, k.

Parameters:
lambda - rates of the hypoexponential distribution
u - value at which the inverse distribution is evaluated
Returns:
inverse distribution at u

setLambda

public void setLambda(double[] lambda)
Description copied from class: HypoExponentialDist
Sets the values λi =lambda[i - 1], i = 1,…, k for this object.

Overrides:
setLambda in class HypoExponentialDist

toString

public String toString()
Overrides:
toString in class HypoExponentialDist

SSJ
V. 2.6.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.