Package jsl.utilities.distributions
Class Distribution
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- All Implemented Interfaces:
ControllableIfc
,CDFIfc
,DistributionFunctionIfc
,DistributionIfc
,InverseCDFIfc
,MeanIfc
,VarianceIfc
,GetNameIfc
,IdentityIfc
,NewInstanceIfc
,ParametersIfc
,GetRVariableIfc
- Direct Known Subclasses:
Bernoulli
,Beta
,Binomial
,Constant
,DEmpiricalCDF
,DUniform
,Exponential
,Gamma
,Geometric
,LogLogistic
,Lognormal
,MTP
,NegativeBinomial
,Normal
,PearsonType5
,PearsonType6
,Poisson
,ShiftedDistribution
,ShiftedGeometric
,StudentT
,Triangular
,TruncatedDistribution
,Uniform
,Weibull
public abstract class Distribution extends java.lang.Object implements DistributionIfc, ControllableIfc, NewInstanceIfc
An Distribution provides a skeletal implementation for classes that must implement the DistributionIfc. This class is an abstract class. Subclasses must provide concrete implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
Distribution.RandomControls
-
Constructor Summary
Constructors Constructor Description Distribution()
Constructs a probability distributionDistribution(java.lang.String name)
Constructs a probability distribution
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Controls
getControls()
Returns a valid instance of Controls that can be used with this ControllableIfc or nullint
getId()
java.lang.String
getName()
RVariableIfc
getRandomVariable(RNStreamIfc rng)
double
getStandardDeviation()
Returns the standard deviation for the probability distribution as the square root of the variance if it existsstatic double
inverseContinuousCDFViaBisection(ContinuousDistributionIfc cdf, double p, double ll, double ul)
Computes the inverse CDF by using the bisection method [ll,ul] must contain the desired value.static double
inverseContinuousCDFViaBisection(ContinuousDistributionIfc cdf, double p, double ll, double ul, double initialX)
Computes the inverse CDF by using the bisection method [ll,ul] must contain the desired value [ll, ul] are defined on the domain of the CDF, i.e.static double
inverseDiscreteCDFViaSearchUp(DiscreteDistributionIfc df, double p, int start)
Searches starting at the value start until the CDF > p "start" must be the smallest possible value for the range of the CDF as an integer.abstract Distribution
newInstance()
Returns a new instancevoid
setControls(Controls controls)
Takes in a valid instance of Controls for this class If controls is null or if it was not created by this class this method should throw an IllegalArgumentExceptionprotected void
setId()
void
setName(java.lang.String str)
Sets the namejava.lang.String
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, cdf, complementaryCDF
-
Methods inherited from interface jsl.utilities.random.rvariable.GetRVariableIfc
getRandomVariable, getRandomVariable
-
Methods inherited from interface jsl.utilities.distributions.InverseCDFIfc
invCDF
-
Methods inherited from interface jsl.utilities.random.ParametersIfc
getParameters, setParameters
-
Methods inherited from interface jsl.utilities.distributions.VarianceIfc
getVariance
-
-
-
-
Method Detail
-
getName
public final java.lang.String getName()
- Specified by:
getName
in interfaceGetNameIfc
- Returns:
- the assigned name
-
setName
public final void setName(java.lang.String str)
Sets the name- Parameters:
str
- The name as a string.
-
getId
public final int getId()
- Specified by:
getId
in interfaceIdentityIfc
- Returns:
- a number identifier
-
setId
protected final void setId()
-
getControls
public Controls getControls()
Description copied from interface:ControllableIfc
Returns a valid instance of Controls that can be used with this ControllableIfc or null- Specified by:
getControls
in interfaceControllableIfc
- Returns:
-
setControls
public void setControls(Controls controls)
Description copied from interface:ControllableIfc
Takes in a valid instance of Controls for this class If controls is null or if it was not created by this class this method should throw an IllegalArgumentException- Specified by:
setControls
in interfaceControllableIfc
-
getStandardDeviation
public final double getStandardDeviation()
Description copied from interface:VarianceIfc
Returns the standard deviation for the probability distribution as the square root of the variance if it exists- Specified by:
getStandardDeviation
in interfaceVarianceIfc
- Returns:
- sqrt(getVariance())
-
newInstance
public abstract Distribution newInstance()
Description copied from interface:NewInstanceIfc
Returns a new instance- Specified by:
newInstance
in interfaceNewInstanceIfc
- Returns:
- the new instance
-
getRandomVariable
public RVariableIfc getRandomVariable(RNStreamIfc rng)
- Specified by:
getRandomVariable
in interfaceGetRVariableIfc
- Parameters:
rng
- the stream to use- Returns:
- a random variable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
inverseContinuousCDFViaBisection
public static double inverseContinuousCDFViaBisection(ContinuousDistributionIfc cdf, double p, double ll, double ul)
Computes the inverse CDF by using the bisection method [ll,ul] must contain the desired value. Initial search point is (ll+ul)/2.0 [ll, ul] are defined on the domain of the CDF, i.e. the X values- Parameters:
cdf
- a reference to the cdfp
- must be in [0,1]ll
- lower limit of search range, must be < ulul
- upper limit of search range, must be > ll- Returns:
- the inverse of the CDF evaluated at p
-
inverseContinuousCDFViaBisection
public static double inverseContinuousCDFViaBisection(ContinuousDistributionIfc cdf, double p, double ll, double ul, double initialX)
Computes the inverse CDF by using the bisection method [ll,ul] must contain the desired value [ll, ul] are defined on the domain of the CDF, i.e. the x values- Parameters:
cdf
- a reference to the cdfp
- must be in [0,1]ll
- lower limit of search range, must be < ulul
- upper limit of search range, must be > llinitialX
- an initial starting point that must be in [ll,ul]- Returns:
- the inverse of the CDF evaluated at p
-
inverseDiscreteCDFViaSearchUp
public static double inverseDiscreteCDFViaSearchUp(DiscreteDistributionIfc df, double p, int start)
Searches starting at the value start until the CDF > p "start" must be the smallest possible value for the range of the CDF as an integer. This requirement is NOT checked Each value is incremented by 1. Thus, the range of possible values for the CDF is assumed to be {start, start + 1, start + 2, etc.}- Parameters:
df
- a reference to the discrete distributionp
- the probability to evaluate, must be (0,1)start
- the initial starting search position- Returns:
- the found inverse of the CDF found for p
-
-