umontreal.iro.lecuyer.probdist
Class TruncatedDist
- java.lang.Object
-
- umontreal.iro.lecuyer.probdist.ContinuousDistribution
-
- umontreal.iro.lecuyer.probdist.TruncatedDist
-
- All Implemented Interfaces:
- Distribution
public class TruncatedDist extends ContinuousDistribution
This container class takes an arbitrary continuous distribution and truncates it to an interval [a, b], where a and b can be finite or infinite. If the original density and distribution function are f0 and F0, the new ones are f and F, defined byf (x) = f0(x)/(F0(b) - F0(a)) for a <= x <= band f (x) = 0 elsewhere, andF(x) = (F0(x) - F0(a))/(F0(b) - F0(a)) for a <= x <= b.The inverse distribution function of the truncated distribution isF-1(u) = F0-1(F0(a) + (F0(b) - F0(a))u)where F0-1 is the inverse distribution function of the original distribution.
-
-
Field Summary
Fields Modifier and Type Field and Description static intNUMINTERVALS-
Fields inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
decPrec
-
-
Constructor Summary
Constructors Constructor and Description TruncatedDist(ContinuousDistribution dist, double a, double b)Constructs a new distribution by truncating distribution dist to the interval [a, b].
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublebarF(double x)Returns the complementary distribution function.doublecdf(double x)Returns the distribution function F(x).doubledensity(double x)Returns f (x), the density evaluated at x.doublegetA()Returns the value of a.doublegetArea()Returns the value of F0(b) - F0(a), the area under the truncated density function.doublegetB()Returns the value of b.doublegetFa()Returns the value of F0(a).doublegetFb()Returns the value of F0(b).doublegetMean()Returns an approximation of the mean computed with the Simpson 1/3 numerical integration rule.double[]getParams()Return a table containing the parameters of the current distribution.doublegetStandardDeviation()Returns the square root of the approximate variance.doublegetVariance()Returns an approximation of the variance computed with the Simpson 1/3 numerical integration rule.doubleinverseF(double u)Returns the inverse distribution function x = F-1(u).voidsetParams(ContinuousDistribution dist, double a, double b)Sets the parameters dist, a and b for this object.java.lang.StringtoString()Returns a String containing information about the current distribution.-
Methods inherited from class umontreal.iro.lecuyer.probdist.ContinuousDistribution
getXinf, getXsup, inverseBisection, inverseBrent, setXinf, setXsup
-
-
-
-
Constructor Detail
-
TruncatedDist
public TruncatedDist(ContinuousDistribution dist, double a, double b)
Constructs a new distribution by truncating distribution dist to the interval [a, b]. Restrictions: a and b must be finite.
-
-
Method Detail
-
density
public double density(double x)
Description copied from class:ContinuousDistributionReturns f (x), the density evaluated at x.- Specified by:
densityin classContinuousDistribution- 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:DistributionReturns the distribution function F(x).- 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:ContinuousDistributionReturns the complementary distribution function. The default implementation computes bar(F)(x) = 1 - F(x).- Specified by:
barFin interfaceDistribution- Overrides:
barFin classContinuousDistribution- 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:ContinuousDistributionReturns the inverse distribution function x = F-1(u). Restrictions: u∈[0, 1].- Specified by:
inverseFin interfaceDistribution- Overrides:
inverseFin classContinuousDistribution- Parameters:
u- value at which the inverse distribution function is evaluated- Returns:
- the inverse distribution function evaluated at u
-
getMean
public double getMean()
Returns an approximation of the mean computed with the Simpson 1/3 numerical integration rule.- Specified by:
getMeanin interfaceDistribution- Overrides:
getMeanin classContinuousDistribution- Returns:
- the mean
- Throws:
java.lang.UnsupportedOperationException- the mean of the truncated distribution is unknown
-
getVariance
public double getVariance()
Returns an approximation of the variance computed with the Simpson 1/3 numerical integration rule.- Specified by:
getVariancein interfaceDistribution- Overrides:
getVariancein classContinuousDistribution- Returns:
- the variance
- Throws:
java.lang.UnsupportedOperationException- the mean of the truncated distribution is unknown
-
getStandardDeviation
public double getStandardDeviation()
Returns the square root of the approximate variance.- Specified by:
getStandardDeviationin interfaceDistribution- Overrides:
getStandardDeviationin classContinuousDistribution- Returns:
- the standard deviation
- Throws:
java.lang.UnsupportedOperationException- the mean of the truncated distribution is unknown
-
getA
public double getA()
Returns the value of a.
-
getB
public double getB()
Returns the value of b.
-
getFa
public double getFa()
Returns the value of F0(a).
-
getFb
public double getFb()
Returns the value of F0(b).
-
getArea
public double getArea()
Returns the value of F0(b) - F0(a), the area under the truncated density function.
-
setParams
public void setParams(ContinuousDistribution dist, double a, double b)
Sets the parameters dist, a and b for this object. See the constructor for details.
-
getParams
public double[] getParams()
Return a table containing the parameters of the current distribution. This table is put in order: [a, b, F0(a), F0(b), F0(b) - F0(a)].
-
toString
public java.lang.String toString()
Returns a String containing information about the current distribution.- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG