Class Uniform
java.lang.Object
random.AbstractDistribution
random.discrete.DiscreteDistribution
random.discrete.Uniform
- All Implemented Interfaces:
StorableDistribution
Discrete uniform distribution over an interval of integers.
-
Field Summary
Fields inherited from class DiscreteDistribution
cached, CDFList, CDFListCalculatedFields inherited from class AbstractDistribution
engine -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecdf(int x) doubleobtain the cumulative distribution from the distributionintgetlower()intgetUpper()booleanintnextRand()Uniform distribution do not need to use inverse Transform Sampling.intGenerate random variables that follow an probability distributiondoublepmf(int x) doubleobtain the probability distribution from the distributiondoubledoubleCalculate the Mean value from the parameter of the distributiondoubledoubleCalculate the Variance from the parameter of the distributionbooleanupdatePar(int a, int b) booleanSub-class must implement this method to update parameter.Methods inherited from class DiscreteDistribution
binarySearch, createdCDFList, createdCDFList, inverseTransformSampling, outdatedMethods inherited from class AbstractDistribution
setRandomEngine
-
Constructor Details
-
Uniform
public Uniform() -
Uniform
-
Uniform
-
-
Method Details
-
updatePar
-
updatePar
Description copied from class:DiscreteDistributionSub-class must implement this method to update parameter.- Specified by:
updateParin classDiscreteDistribution- Throws:
IncorrectDistributionParameterException
-
getUpper
public int getUpper()- Specified by:
getUpperin classDiscreteDistribution
-
getlower
public int getlower()- Specified by:
getlowerin classDiscreteDistribution
-
nextBoolean
public boolean nextBoolean() -
nextRand
public int nextRand()Uniform distribution do not need to use inverse Transform Sampling. The random variable can directly generated from the inverse function.- Specified by:
nextRandin classDiscreteDistribution
-
pmf
public double pmf(int x) - Specified by:
pmfin classDiscreteDistribution
-
cdf
public double cdf(int x) - Specified by:
cdfin classDiscreteDistribution
-
theorMean
public double theorMean()- Specified by:
theorMeanin classDiscreteDistribution
-
theorVariance
public double theorVariance()- Specified by:
theorVariancein classDiscreteDistribution
-
nextRand
Description copied from class:DiscreteDistributionGenerate random variables that follow an probability distribution- Specified by:
nextRandin classDiscreteDistribution- Parameters:
p- parameter of the distribution.- Returns:
- int - random variables that follow an probability distribution
- Throws:
IncorrectDistributionParameterException
-
pmf
Description copied from class:DiscreteDistributionobtain the probability distribution from the distribution- Specified by:
pmfin classDiscreteDistribution- Parameters:
x- int - random variable indicating where to evaluate the pmf.p- parameter of the distribution.- Returns:
- double - the probability weight evaluated at x.
- Throws:
IncorrectDistributionParameterException
-
cdf
Description copied from class:DiscreteDistributionobtain the cumulative distribution from the distribution- Specified by:
cdfin classDiscreteDistribution- Parameters:
x- int - random variable indicating where to evaluate the cdf.p- parameter of the distribution.- Returns:
- double - the probability weight cumulated at x.
- Throws:
IncorrectDistributionParameterException
-
theorMean
Description copied from class:DiscreteDistributionCalculate the Mean value from the parameter of the distribution- Specified by:
theorMeanin classDiscreteDistribution- Parameters:
p- parameter of the distribution.- Returns:
- double - theoretic mean value of the distribution.
- Throws:
IncorrectDistributionParameterException
-
theorVariance
Description copied from class:DiscreteDistributionCalculate the Variance from the parameter of the distribution- Specified by:
theorVariancein classDiscreteDistribution- Parameters:
p- parameter of the distribution.- Returns:
- double - theoretic variance value of the distribution.
- Throws:
IncorrectDistributionParameterException
-