SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.probdist.InverseDistFromDensity Class Reference

Implements a method for computing the inverse of an arbitrary continuous distribution function when only the probability density is known. More...

Inheritance diagram for umontreal.ssj.probdist.InverseDistFromDensity:
umontreal.ssj.probdist.ContinuousDistribution umontreal.ssj.probdist.Distribution

Public Member Functions

 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.
double density (double x)
 Computes the probability density at \(x\).
double cdf (double x)
 Computes the distribution function at \(x\).
double inverseF (double u)
 Computes the inverse distribution function at \(u\).
double getXc ()
 Returns the xc given in the constructor.
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.
String toString ()
 Returns a String containing information about the current distribution.
Public Member Functions inherited from umontreal.ssj.probdist.ContinuousDistribution
double barF (double x)
 Returns the complementary distribution function.
double inverseBrent (double a, double b, double u, double tol)
 Computes the inverse distribution function \(x = F^{-1}(u)\), using the Brent-Dekker method.
double inverseBisection (double u)
 Computes and returns the inverse distribution function \(x = F^{-1}(u)\), using bisection.
double getMean ()
 Returns the mean.
double getVariance ()
 Returns the variance.
double getStandardDeviation ()
 Returns the standard deviation.
double getXinf ()
 Returns \(x_a\) such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).
double getXsup ()
 Returns \(x_b\) such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).
void setXinf (double xa)
 Sets the value \(x_a=\) xa, such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).
void setXsup (double xb)
 Sets the value \(x_b=\) xb, such that the probability density is 0 everywhere outside the interval \([x_a, x_b]\).

Detailed Description

Implements a method for computing the inverse of an arbitrary continuous distribution function when only the probability density is known.

[42] . 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 \(\alpha< 1\)) if one chooses too high a precision (a too small eps, for ex. \(\epsilon\sim10^{-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 umontreal.ssj.randvar.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.

 <div class="SSJ-bigskip"></div>

Definition at line 65 of file InverseDistFromDensity.java.

Constructor & Destructor Documentation

◆ InverseDistFromDensity() [1/2]

umontreal.ssj.probdist.InverseDistFromDensity.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.

The user may wish to set the left and the right boundaries between which the density is non-zero by calling methods umontreal.ssj.probdist.ContinuousDistribution.setXinf and umontreal.ssj.probdist.ContinuousDistribution.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 \le\mathtt{order} \le12\).

Definition at line 237 of file InverseDistFromDensity.java.

◆ InverseDistFromDensity() [2/2]

umontreal.ssj.probdist.InverseDistFromDensity.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.

The left and the right boundaries of the density are xleft and xright (the density is 0 outside the interval [xleft, xright]). See the description of the other constructor.

Definition at line 249 of file InverseDistFromDensity.java.

Member Function Documentation

◆ cdf()

double umontreal.ssj.probdist.InverseDistFromDensity.cdf ( double x)

Computes the distribution function at \(x\).

Implements umontreal.ssj.probdist.Distribution.

Definition at line 266 of file InverseDistFromDensity.java.

◆ density()

double umontreal.ssj.probdist.InverseDistFromDensity.density ( double x)

Computes the probability density at \(x\).

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 259 of file InverseDistFromDensity.java.

◆ getEpsilon()

double umontreal.ssj.probdist.InverseDistFromDensity.getEpsilon ( )

Returns the \(u\)-resolution eps associated with this object.

Definition at line 304 of file InverseDistFromDensity.java.

◆ getOrder()

int umontreal.ssj.probdist.InverseDistFromDensity.getOrder ( )

Returns the order associated with this object.

Definition at line 311 of file InverseDistFromDensity.java.

◆ getParams()

double[] umontreal.ssj.probdist.InverseDistFromDensity.getParams ( )

Return a table containing the parameters of the current distribution.

This table is returned as: [xc, eps, order].

Implements umontreal.ssj.probdist.Distribution.

Definition at line 319 of file InverseDistFromDensity.java.

◆ getXc()

double umontreal.ssj.probdist.InverseDistFromDensity.getXc ( )

Returns the xc given in the constructor.

Definition at line 297 of file InverseDistFromDensity.java.

◆ inverseF()

double umontreal.ssj.probdist.InverseDistFromDensity.inverseF ( double u)

Computes the inverse distribution function at \(u\).

Reimplemented from umontreal.ssj.probdist.ContinuousDistribution.

Definition at line 273 of file InverseDistFromDensity.java.

◆ toString()

String umontreal.ssj.probdist.InverseDistFromDensity.toString ( )

Returns a String containing information about the current distribution.

Definition at line 327 of file InverseDistFromDensity.java.


The documentation for this class was generated from the following file: