Package jsl.utilities.distributions
Class Uniform
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.Uniform
-
- All Implemented Interfaces:
ControllableIfc
,CDFIfc
,ContinuousDistributionIfc
,DistributionFunctionIfc
,DistributionIfc
,DomainIfc
,InverseCDFIfc
,MeanIfc
,PDFIfc
,VarianceIfc
,GetNameIfc
,IdentityIfc
,NewInstanceIfc
,ParametersIfc
,GetRVariableIfc
public class Uniform extends Distribution implements ContinuousDistributionIfc, InverseCDFIfc, GetRVariableIfc
Defines a uniform distribution over the given range.
-
-
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 Uniform()
Constructs a uniform distribution over the range (0,1)Uniform(double[] parameters)
Constructs a uniform distribution with lower limit = parameters[0], upper limit = parameters[1]Uniform(double lowerLimit, double upperLimit)
Constructs a uniform distribution over the provided rangeUniform(double lowerLimit, double upperLimit, java.lang.String name)
Constructs a uniform distribution over the provided range
-
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 functionInterval
getDomain()
double
getKurtosis()
Gets the kurtosis of the distribution www.mathworld.wolfram.com/UniformDistribution.htmldouble
getMaximum()
Gets the upper limit of the distributiondouble
getMean()
Returns the mean or expected value of a distributiondouble
getMinimum()
Gets the lower limit for the distributiondouble
getMoment3()
double
getMoment4()
double[]
getParameters()
Gets the parameters for the distributionRVariableIfc
getRandomVariable(RNStreamIfc rng)
double
getRange()
double
getSkewness()
Gets the skewness of the distribution www.mathworld.wolfram.com/UniformDistribution.htmldouble
getVariance()
Returns the variance of the distribution if defineddouble
invCDF(double prob)
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.Uniform
newInstance()
Returns a new instancedouble
pdf(double x)
Returns the f(x) where f represents the probability density function for the distribution.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.void
setParameters(double min, double max)
Sets the minimum and maximum value of the distribution throws IllegalArgumentException when if min >= maxvoid
setRange(double min, double max)
Sets the range-
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
-
Uniform
public Uniform()
Constructs a uniform distribution over the range (0,1)
-
Uniform
public Uniform(double[] parameters)
Constructs a uniform distribution with lower limit = parameters[0], upper limit = parameters[1]- Parameters:
parameters
- The array of parameters
-
Uniform
public Uniform(double lowerLimit, double upperLimit)
Constructs a uniform distribution over the provided range- Parameters:
lowerLimit
- limit of the distributionupperLimit
- limit of the distribution
-
Uniform
public Uniform(double lowerLimit, double upperLimit, java.lang.String name)
Constructs a uniform distribution over the provided range- Parameters:
lowerLimit
- limit of the distributionupperLimit
- limit of the distributionname
- an optional name/label
-
-
Method Detail
-
newInstance
public final Uniform newInstance()
Description copied from interface:NewInstanceIfc
Returns a new instance- Specified by:
newInstance
in interfaceNewInstanceIfc
- Specified by:
newInstance
in classDistribution
- Returns:
- the new instance
-
getMinimum
public final double getMinimum()
Gets the lower limit for the distribution- Returns:
- The lower limit
-
getMaximum
public final double getMaximum()
Gets the upper limit of the distribution- Returns:
- The upper limit
-
setParameters
public final void setParameters(double min, double max)
Sets the minimum and maximum value of the distribution throws IllegalArgumentException when if min >= max- Parameters:
min
- The minimum value of the distributionmax
- The maximum value of the distribution
-
setRange
public final void setRange(double min, double max)
Sets the range- Parameters:
min
- The lower limit for the distributionmax
- The upper limit for the distribution
-
getRange
public final double getRange()
- Returns:
- the range (max - min)
-
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
-
invCDF
public final double invCDF(double prob)
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:
prob
- 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
-
pdf
public final double pdf(double x)
Description copied from interface:PDFIfc
Returns the f(x) where f represents the probability density function for the distribution. Note this is not a probability.
-
getMean
public final double getMean()
Description copied from interface:MeanIfc
Returns the mean or expected value of a distribution
-
getMoment3
public final double getMoment3()
- Returns:
- the 3rd moment
-
getMoment4
public final double getMoment4()
- Returns:
- the 4th moment
-
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
-
getKurtosis
public final double getKurtosis()
Gets the kurtosis of the distribution www.mathworld.wolfram.com/UniformDistribution.html- Returns:
- the kurtosis
-
getSkewness
public final double getSkewness()
Gets the skewness of the distribution www.mathworld.wolfram.com/UniformDistribution.html- Returns:
- the skewness
-
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:
setParameters
in 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:
getParameters
in interfaceParametersIfc
- Returns:
- Returns an array of the parameters for the distribution
-
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
-
-