Package jsl.utilities.distributions
Class DUniform
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.DUniform
-
- All Implemented Interfaces:
ControllableIfc,CDFIfc,DiscreteDistributionIfc,DistributionFunctionIfc,DistributionIfc,InverseCDFIfc,MeanIfc,PMFIfc,VarianceIfc,GetNameIfc,IdentityIfc,NewInstanceIfc,ParametersIfc,GetRVariableIfc
public class DUniform extends Distribution implements DiscreteDistributionIfc, GetRVariableIfc
Models discrete random variables that are uniformly distributed over a contiguous range of integers.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.utilities.distributions.Distribution
Distribution.RandomControls
-
-
Field Summary
-
Fields inherited from class jsl.utilities.distributions.Distribution
myId, myName
-
-
Constructor Summary
Constructors Constructor Description DUniform()Constructs a discrete uniform over the range {0,1}DUniform(double[] parameters)Constructs a discrete uniform where parameter[0] is the lower slimit and parameter[1] is the upper limit of the range.DUniform(int minimum, int maximum)Constructs a discrete uniform over the supplied range the lower limit must be < upper limitDUniform(int minimum, int maximum, java.lang.String name)Constructs a discrete uniform over the supplied range the lower limit must be < upper limit
-
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 functionintgetMaximum()Gets the distribution's upper limitdoublegetMean()Returns the mean or expected value of a distributionintgetMinimum()Gets the distribution's lower limitdouble[]getParameters()Gets the parameters for the distributionRVariableIfcgetRandomVariable(RNStreamIfc rng)intgetRange()The discrete maximum - minimum + 1doublegetVariance()Returns the variance of the distribution if defineddoubleinvCDF(double prob)Provides the inverse cumulative distribution function for the distributionDUniformnewInstance()Returns a new instance of the random source with the same parameters but an independent generatordoublepmf(double x)If x is not and integer value, then the probability must be zero otherwise pmf(int x) is used to determine the probabilitydoublepmf(int x)Returns the probability associated with xvoidsetParameters(double[] parameters)Sets the parameters for the distribution where parameters[0] is the lowerlimit and parameters[1] is the upper limit of the range.voidsetRange(int minimum, int maximum)Sets the range for the distribution the lower limit must be < upper limit-
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
-
-
-
-
Constructor Detail
-
DUniform
public DUniform()
Constructs a discrete uniform over the range {0,1}
-
DUniform
public DUniform(double[] parameters)
Constructs a discrete uniform where parameter[0] is the lower slimit and parameter[1] is the upper limit of the range. the lower limit must be < upper limit- Parameters:
parameters- A array containing the lower limit and upper limit
-
DUniform
public DUniform(int minimum, int maximum)Constructs a discrete uniform over the supplied range the lower limit must be < upper limit- Parameters:
minimum- The lower limit of the rangemaximum- The upper limit of the range
-
DUniform
public DUniform(int minimum, int maximum, java.lang.String name)Constructs a discrete uniform over the supplied range the lower limit must be < upper limit- Parameters:
minimum- The lower limit of the rangemaximum- The upper limit of the rangename- an optional name/label
-
-
Method Detail
-
newInstance
public final DUniform newInstance()
Returns a new instance of the random source with the same parameters but an independent generator- Specified by:
newInstancein interfaceNewInstanceIfc- Specified by:
newInstancein classDistribution- Returns:
-
getMinimum
public final int getMinimum()
Gets the distribution's lower limit- Returns:
- The lower limit
-
getMaximum
public final int getMaximum()
Gets the distribution's upper limit- Returns:
- The upper limit
-
setRange
public final void setRange(int minimum, int maximum)Sets the range for the distribution the lower limit must be < upper limit- Parameters:
minimum- The lower limit for the rangemaximum- The upper limit for the range
-
getRange
public final int getRange()
The discrete maximum - minimum + 1- Returns:
- the returned range
-
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
-
invCDF
public final double invCDF(double prob)
Provides the inverse cumulative distribution function for the distribution- Specified by:
invCDFin interfaceInverseCDFIfc- Parameters:
prob- The probability to be evaluated for the inverse, prob must be [0,1] or an IllegalArgumentException is thrown- Returns:
- The inverse cdf evaluated at the supplied probability
-
pmf
public final double pmf(double x)
If x is not and integer value, then the probability must be zero otherwise pmf(int x) is used to determine the probability
-
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
-
pmf
public final double pmf(int x)
Returns the probability associated with x- Parameters:
x- the value to evaluate- Returns:
- the associated probability
-
setParameters
public final void setParameters(double[] parameters)
Sets the parameters for the distribution where parameters[0] is the lowerlimit and parameters[1] is the upper limit of the range. the lower limit must be < upper limit- Specified by:
setParametersin interfaceParametersIfc- Parameters:
parameters- an array of doubles representing the parameters for the distribution
-
getParameters
public final double[] getParameters()
Gets the parameters for the distribution- Specified by:
getParametersin interfaceParametersIfc- Returns:
- Returns an array of the parameters for the distribution
-
getRandomVariable
public final RVariableIfc getRandomVariable(RNStreamIfc rng)
- Specified by:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
-