|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object umontreal.iro.lecuyer.probdist.ContinuousDistribution umontreal.iro.lecuyer.probdist.InverseDistFromDensity
public class InverseDistFromDensity
Implements a method for computing the inverse of an arbitrary continuous distribution function when only the probability density is known. The cumulative probabilities (cdf) are pre-computed by numerical quadrature of the density using Gauss-Lobatto integration over suitably small intervals to satisfy the required precision, and these values are kept in tables. Then the algorithm uses polynomial interpolation over the tabulated values to get the inverse cdf. The user can select the desired precision and the degree of the interpolating polynomials.
The algorithm may fail for some distributions for which the density becomes infinite at a point (for ex. the Gamma and the Beta distributions with α < 1) if one chooses too high a precision (a too small eps, for ex. ε∼10-15). However, it should work also for continuous densities with finite discontinuities.
While the setup time for this class is relatively slow, the numerical inversion
is extremely fast and practically independent of the required precision
and of the specific distribution. For comparisons between the times
of standard inversion and inversion from this class as well as
comparisons between setup times, see the introduction in class
InverseFromDensityGen
from package randvar.
Thus if only a few inverses are needed, then using this class is not efficient because of the slow set-up. But if one wants to call inverseF thousands of times or more, then using this class will be very efficient.
Field Summary |
---|
Fields inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution |
---|
decPrec |
Constructor Summary | |
---|---|
InverseDistFromDensity(ContinuousDistribution dist,
double xc,
double eps,
int order)
Given a continuous distribution dist with a well-defined density method, this class will compute tables for the numerical inverse of the distribution. |
|
InverseDistFromDensity(MathFunction dens,
double xc,
double eps,
int order,
double xleft,
double xright)
Given a continuous probability density dens, this class will compute tables for the numerical inverse of the distribution. |
Method Summary | |
---|---|
double |
cdf(double x)
Computes the distribution function at x. |
double |
density(double x)
Computes the probability density at x. |
double |
getEpsilon()
Returns the u-resolution eps associated with this object. |
int |
getOrder()
Returns the order associated with this object. |
double[] |
getParams()
Return a table containing the parameters of the current distribution. |
double |
getXc()
Returns the xc given in the constructor. |
double |
inverseF(double u)
Computes the inverse distribution function at u. |
String |
toString()
Returns a String containing information about the current distribution. |
Methods inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution |
---|
barF, getMean, getStandardDeviation, getVariance, getXinf, getXsup, inverseBisection, inverseBrent, setXinf, setXsup |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public InverseDistFromDensity(ContinuousDistribution dist, double xc, double eps, int order)
setXinf
and
setXsup
of dist, for better efficiency.
Argument xc can be the mean,
the mode or any other x for which the density is relatively large.
The u-resolution eps is the required absolute error in the cdf,
and order is the degree of the
Newton interpolating polynomial over each interval.
An order of 3 or 5, and an eps of 10-6 to 10-12
are usually good choices.
Restrictions:
3 <=
public InverseDistFromDensity(MathFunction dens, double xc, double eps, int order, double xleft, double xright)
Method Detail |
---|
public double density(double x)
density
in class ContinuousDistribution
x
- value at which the density is evaluated
public double cdf(double x)
x
- value at which the distribution function is evaluated
public double inverseF(double u)
inverseF
in interface Distribution
inverseF
in class ContinuousDistribution
u
- value at which the inverse distribution function is evaluated
public double getXc()
public double getEpsilon()
public int getOrder()
public double[] getParams()
public String toString()
toString
in class Object
|
SSJ V. 2.6.2. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |