Package jsl.utilities.distributions
Class TruncatedDistribution
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.TruncatedDistribution
-
- All Implemented Interfaces:
ControllableIfc,CDFIfc,DistributionFunctionIfc,DistributionIfc,InverseCDFIfc,MeanIfc,VarianceIfc,GetNameIfc,IdentityIfc,NewInstanceIfc,ParametersIfc,GetRVariableIfc
public class TruncatedDistribution extends Distribution implements GetRVariableIfc
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.utilities.distributions.Distribution
Distribution.RandomControls
-
-
Field Summary
Fields Modifier and Type Field Description protected doublemyCDFLLprotected doublemyCDFULprotected doublemyDeltaFUFLprotected DistributionIfcmyDistributionprotected doublemyFofLLprotected doublemyFofULprotected doublemyLowerLimitprotected doublemyUpperLimit-
Fields inherited from class jsl.utilities.distributions.Distribution
myId, myName
-
-
Constructor Summary
Constructors Constructor Description TruncatedDistribution(DistributionIfc distribution, double cdfLL, double cdfUL, double truncLL, double truncUL)Constructs a truncated distribution based on the provided distributionTruncatedDistribution(DistributionIfc distribution, double cdfLL, double cdfUL, double truncLL, double truncUL, java.lang.String name)Constructs a truncated distribution based on the provided distribution
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecdf(double x)Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution functiondoublegetCDFLowerLimit()The CDF's original lower limitdoublegetCDFUpperLimit()The CDF's original upper limitdoublegetMean()Returns the mean or expected value of a distributiondouble[]getParameters()Get the parameters for the truncated distributionRVariableIfcgetRandomVariable(RNStreamIfc rng)doublegetTruncatedLowerLimit()The lower limit for the truncated distributiondoublegetTruncatedUpperLimit()The upper limit for the trunctated distributiondoublegetVariance()Returns the variance of the distribution if defineddoubleinvCDF(double p)Provides the inverse cumulative distribution function for the distribution While closed form solutions for the inverse cdf may not exist, numerical search methods can be used to solve F(X) = U.TruncatedDistributionnewInstance()Returns a new instance of the random source with the same parametersvoidsetDistribution(DistributionIfc distribution, double cdfLL, double cdfUL, double truncLL, double truncUL)voidsetLimits(double cdfLL, double cdfUL, double truncLL, double truncUL)voidsetParameters(double[] parameters)Sets the parameters of the truncated distribution cdfLL = parameter[0] cdfUL = parameters[1] truncLL = parameters[2] truncUL = parameters[3]-
Methods inherited from class jsl.utilities.distributions.Distribution
getControls, getId, getName, getStandardDeviation, inverseContinuousCDFViaBisection, inverseContinuousCDFViaBisection, inverseDiscreteCDFViaSearchUp, setControls, setId, setName, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.distributions.CDFIfc
cdf, complementaryCDF
-
Methods inherited from interface jsl.utilities.random.rvariable.GetRVariableIfc
getRandomVariable, getRandomVariable
-
-
-
-
Field Detail
-
myDistribution
protected DistributionIfc myDistribution
-
myLowerLimit
protected double myLowerLimit
-
myUpperLimit
protected double myUpperLimit
-
myCDFLL
protected double myCDFLL
-
myCDFUL
protected double myCDFUL
-
myFofLL
protected double myFofLL
-
myFofUL
protected double myFofUL
-
myDeltaFUFL
protected double myDeltaFUFL
-
-
Constructor Detail
-
TruncatedDistribution
public TruncatedDistribution(DistributionIfc distribution, double cdfLL, double cdfUL, double truncLL, double truncUL)
Constructs a truncated distribution based on the provided distribution- Parameters:
distribution- the distribution to truncate, must not be nullcdfLL- The lower limit of the range of support of the distributioncdfUL- The upper limit of the range of support of the distributiontruncLL- The truncated lower limit (if moved in from cdfLL), must be >= cdfLLtruncUL- The truncated upper limit (if moved in from cdfUL), must be <= cdfUL
-
TruncatedDistribution
public TruncatedDistribution(DistributionIfc distribution, double cdfLL, double cdfUL, double truncLL, double truncUL, java.lang.String name)
Constructs a truncated distribution based on the provided distribution- Parameters:
distribution- the distribution to truncate, must not be nullcdfLL- The lower limit of the range of support of the distributioncdfUL- The upper limit of the range of support of the distributiontruncLL- The truncated lower limit (if moved in from cdfLL), must be >= cdfLLtruncUL- The truncated upper limit (if moved in from cdfUL), must be <= cdfULname- an optional name/label
-
-
Method Detail
-
newInstance
public final TruncatedDistribution newInstance()
Returns a new instance of the random source with the same parameters- Specified by:
newInstancein interfaceNewInstanceIfc- Specified by:
newInstancein classDistribution- Returns:
- the new instance
-
setDistribution
public final void setDistribution(DistributionIfc distribution, double cdfLL, double cdfUL, double truncLL, double truncUL)
- Parameters:
distribution- the distribution to truncate, must not be nullcdfLL- The lower limit of the range of support of the distributioncdfUL- The upper limit of the range of support of the distributiontruncLL- The truncated lower limit (if moved in from cdfLL), must be >= cdfLLtruncUL- The truncated upper limit (if moved in from cdfUL), must be <= cdfUL
-
setLimits
public final void setLimits(double cdfLL, double cdfUL, double truncLL, double truncUL)- Parameters:
cdfLL- The lower limit of the range of support of the distributioncdfUL- The upper limit of the range of support of the distributiontruncLL- The truncated lower limit (if moved in from cdfLL), must be >= cdfLLtruncUL- The truncated upper limit (if moved in from cdfUL), must be <= cdfUL
-
setParameters
public final void setParameters(double[] parameters)
Sets the parameters of the truncated distribution cdfLL = parameter[0] cdfUL = parameters[1] truncLL = parameters[2] truncUL = parameters[3]any other values in the array should be interpreted as the parameters for the underlying distribution
- Specified by:
setParametersin interfaceParametersIfc- Parameters:
parameters- an array of doubles representing the parameters
-
getParameters
public final double[] getParameters()
Get the parameters for the truncated distributioncdfLL = parameter[0] cdfUL = parameters[1] truncLL = parameters[2] truncUL = parameters[3]
any other values in the array should be interpreted as the parameters for the underlying distribution
- Specified by:
getParametersin interfaceParametersIfc- Returns:
- Returns an array of the parameters
-
getCDFLowerLimit
public final double getCDFLowerLimit()
The CDF's original lower limit- Returns:
- CDF's original lower limit
-
getCDFUpperLimit
public final double getCDFUpperLimit()
The CDF's original upper limit- Returns:
- CDF's original upper limit
-
getTruncatedLowerLimit
public final double getTruncatedLowerLimit()
The lower limit for the truncated distribution- Returns:
- lower limit for the truncated distribution
-
getTruncatedUpperLimit
public final double getTruncatedUpperLimit()
The upper limit for the trunctated distribution- Returns:
- upper limit for the trunctated distribution
-
cdf
public final double cdf(double x)
Description copied from interface:CDFIfcReturns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
getMean
public final double getMean()
Description copied from interface:MeanIfcReturns the mean or expected value of a distribution
-
getVariance
public final double getVariance()
Description copied from interface:VarianceIfcReturns the variance of the distribution if defined- Specified by:
getVariancein interfaceVarianceIfc- Returns:
- double the variance of the random variable
-
invCDF
public double invCDF(double p)
Description copied from interface:InverseCDFIfcProvides the inverse cumulative distribution function for the distribution While closed form solutions for the inverse cdf may not exist, numerical search methods can be used to solve F(X) = U.- Specified by:
invCDFin interfaceInverseCDFIfc- Parameters:
p- The probability to be evaluated for the inverse, p must be [0,1] or an IllegalArgumentException is thrown- Returns:
- The inverse cdf evaluated at the supplied probability
-
getRandomVariable
public final RVariableIfc getRandomVariable(RNStreamIfc rng)
- Specified by:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
-