Class DiscreteDistributionInt
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
-
- All Implemented Interfaces:
- Distribution
- Direct Known Subclasses:
- BernoulliDist, BinomialDist, GeometricDist, HypergeometricDist, LogarithmicDist, NegativeBinomialDist, PoissonDist, UniformIntDist
public abstract class DiscreteDistributionInt extends java.lang.Object implements Distribution
Classes implementing discrete distributions over the integers should inherit from this class. It specifies the signatures of methods for computing the mass function (or probability) p(x) = P[X = x], distribution function F(x), complementary distribution function bar(F)(x), and inverse distribution function F-1(u), for a random variable X with a discrete distribution over the integers.WARNING: the complementary distribution function is defined as bar(F)(j) = P[X >= j] (for integers j, so that for discrete distributions in SSJ, F(j) + bar(F)(j)≠1 since both include the term P[X = j].
The implementing classes provide both static and non-static methods to compute the above functions. The non-static methods require the creation of an object of class
DiscreteDistributionInt; all the non-negligible terms of the mass and distribution functions will be precomputed by the constructor and kept in arrays. Subsequent accesses will be very fast. The static methods do not require the construction of an object. These static methods are not specified in this abstract class because the number and types of their parameters depend on the distribution. When methods have to be called several times with the same parameters for the distributions, it is usually more efficient to create an object and use its non-static methods instead of the static ones. This trades memory for speed.
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleEPSILONEnvironment variable that determines what probability terms can be considered as negligible when building precomputed tables for distribution and mass functions.
-
Constructor Summary
Constructors Constructor and Description DiscreteDistributionInt()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description doublebarF(double x)Returns bar(F)(x), the complementary distribution function.doublebarF(int x)Returns bar(F)(x), the complementary distribution function.doublecdf(double x)Returns the distribution function F evaluated at x (see).abstract doublecdf(int x)Returns the distribution function F evaluated at x (see).intgetXinf()Returns the lower limit xa of the support of the probability mass function.intgetXsup()Returns the upper limit xb of the support of the probability mass function.doubleinverseF(double u)Returns the inverse distribution function F-1(u), where 0 <= u <= 1.intinverseFInt(double u)Returns the inverse distribution function F-1(u), where 0 <= u <= 1.abstract doubleprob(int x)Returns p(x), the probability of x, which should be a real number in the interval [0, 1].-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface umontreal.iro.lecuyer.probdist.Distribution
getMean, getParams, getStandardDeviation, getVariance
-
-
-
-
Field Detail
-
EPSILON
public static double EPSILON
Environment variable that determines what probability terms can be considered as negligible when building precomputed tables for distribution and mass functions. Probabilities smaller than EPSILON are not stored in theDiscreteDistributionobjects (such as those of classPoissonDist, etc.), but are computed directly each time they are needed (which should be very seldom). The default value is set to 10-16.
-
-
Method Detail
-
prob
public abstract double prob(int x)
Returns p(x), the probability of x, which should be a real number in the interval [0, 1].- Parameters:
x- value at which the mass function must be evaluated- Returns:
- the mass function evaluated at x
-
cdf
public double cdf(double x)
Returns the distribution function F evaluated at x (see). Calls thecdf(int) method.- Specified by:
cdfin interfaceDistribution- Parameters:
x- value at which the distribution function must be evaluated- Returns:
- the distribution function evaluated at x
-
cdf
public abstract double cdf(int x)
Returns the distribution function F evaluated at x (see).- Parameters:
x- value at which the distribution function must be evaluated- Returns:
- the distribution function evaluated at x
-
barF
public double barF(double x)
Returns bar(F)(x), the complementary distribution function. Calls thebarF(int) method.- Specified by:
barFin interfaceDistribution- Parameters:
x- value at which the complementary distribution function must be evaluated- Returns:
- the complementary distribution function evaluated at x
-
barF
public double barF(int x)
Returns bar(F)(x), the complementary distribution function. See the WARNING above.- Parameters:
x- value at which the complementary distribution function must be evaluated- Returns:
- the complementary distribution function evaluated at x
-
getXinf
public int getXinf()
Returns the lower limit xa of the support of the probability mass function. The probability is 0 for all x < xa.- Returns:
- x lower limit of support
-
getXsup
public int getXsup()
Returns the upper limit xb of the support of the probability mass function. The probability is 0 for all x > xb.- Returns:
- x upper limit of support
-
inverseF
public double inverseF(double u)
Returns the inverse distribution function F-1(u), where 0 <= u <= 1. Calls the inverseFInt method.- Specified by:
inverseFin interfaceDistribution- Parameters:
u- value in the interval (0, 1) for which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
- Throws:
java.lang.IllegalArgumentException- if u is not in the interval (0, 1)java.lang.ArithmeticException- if the inverse cannot be computed, for example if it would give infinity in a theoritical context
-
inverseFInt
public int inverseFInt(double u)
Returns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.- Parameters:
u- value in the interval (0, 1) for which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
- Throws:
java.lang.IllegalArgumentException- if u is not in the interval (0, 1)java.lang.ArithmeticException- if the inverse cannot be computed, for example if it would give infinity in a theoritical context
-
-
DMelt 3.0 © DataMelt by jWork.ORG