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 double
myCDFLL
protected double
myCDFUL
protected double
myDeltaFUFL
protected DistributionIfc
myDistribution
protected double
myFofLL
protected double
myFofUL
protected double
myLowerLimit
protected double
myUpperLimit
-
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 double
cdf(double x)
Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution functiondouble
getCDFLowerLimit()
The CDF's original lower limitdouble
getCDFUpperLimit()
The CDF's original upper limitdouble
getMean()
Returns the mean or expected value of a distributiondouble[]
getParameters()
Get the parameters for the truncated distributionRVariableIfc
getRandomVariable(RNStreamIfc rng)
double
getTruncatedLowerLimit()
The lower limit for the truncated distributiondouble
getTruncatedUpperLimit()
The upper limit for the trunctated distributiondouble
getVariance()
Returns the variance of the distribution if defineddouble
invCDF(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.TruncatedDistribution
newInstance()
Returns a new instance of the random source with the same parametersvoid
setDistribution(DistributionIfc distribution, double cdfLL, double cdfUL, double truncLL, double truncUL)
void
setLimits(double cdfLL, double cdfUL, double truncLL, double truncUL)
void
setParameters(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:
newInstance
in interfaceNewInstanceIfc
- Specified by:
newInstance
in 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:
setParameters
in 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:
getParameters
in 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:CDFIfc
Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
getMean
public final double getMean()
Description copied from interface:MeanIfc
Returns the mean or expected value of a distribution
-
getVariance
public final double getVariance()
Description copied from interface:VarianceIfc
Returns the variance of the distribution if defined- Specified by:
getVariance
in interfaceVarianceIfc
- Returns:
- double the variance of the random variable
-
invCDF
public double invCDF(double p)
Description copied from interface:InverseCDFIfc
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.- Specified by:
invCDF
in 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:
getRandomVariable
in interfaceGetRVariableIfc
- Overrides:
getRandomVariable
in classDistribution
- Parameters:
rng
- the stream to use- Returns:
- a random variable
-
-