Package jsl.utilities.distributions
Class Constant
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.Constant
-
- All Implemented Interfaces:
ControllableIfc,CDFIfc,DiscreteDistributionIfc,DistributionFunctionIfc,DistributionIfc,InverseCDFIfc,MeanIfc,PMFIfc,VarianceIfc,GetNameIfc,IdentityIfc,NewInstanceIfc,ParametersIfc,GetRVariableIfc
- Direct Known Subclasses:
VConstant
public class Constant extends Distribution implements DiscreteDistributionIfc, GetRVariableIfc
Constructs a degenerate distribution with all probability at the provided point. Once made the value of the constant cannot be changed.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.utilities.distributions.Distribution
Distribution.RandomControls
-
-
Field Summary
Fields Modifier and Type Field Description protected doublemyValuestatic ConstantONEA constant to represent one for sharingstatic ConstantPOSITIVE_INFINITYA constant to represent positive infinity for sharingstatic ConstantTWOA constant to represent two for sharingstatic ConstantZEROA constant to represent zero for sharing-
Fields inherited from class jsl.utilities.distributions.Distribution
myId, myName
-
-
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 functiondoublegetMean()Returns the mean or expected value of a distributiondouble[]getParameters()Gets the parametersRVariableIfcgetRandomVariable(RNStreamIfc rng)doublegetVariance()Returns the variance of the distribution if defineddoubleinvCDF(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.ConstantnewInstance()Returns a new instancedoublepmf(double x)Returns the f(x) where f represents the probability mass function for the distribution.voidsetParameters(double[] parameters)Sets the parameters-
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
-
ZERO
public static final Constant ZERO
A constant to represent zero for sharing
-
ONE
public static final Constant ONE
A constant to represent one for sharing
-
TWO
public static final Constant TWO
A constant to represent two for sharing
-
POSITIVE_INFINITY
public static final Constant POSITIVE_INFINITY
A constant to represent positive infinity for sharing
-
myValue
protected double myValue
-
-
Constructor Detail
-
Constant
public Constant(double value)
Construct a constant using the supplied value- Parameters:
value- the value for the constant
-
Constant
public Constant(double[] parameters)
- Parameters:
parameters- the parameter[0] is the value
-
Constant
public Constant(double value, java.lang.String name)Construct a constant using the supplied value- Parameters:
value- the value for the constantname- a string name/label
-
-
Method Detail
-
newInstance
public Constant newInstance()
Description copied from interface:NewInstanceIfcReturns a new instance- Specified by:
newInstancein interfaceNewInstanceIfc- Specified by:
newInstancein classDistribution- Returns:
- the new instance
-
setParameters
public void setParameters(double[] parameters)
Description copied from interface:ParametersIfcSets the parameters- Specified by:
setParametersin interfaceParametersIfc- Parameters:
parameters- an array of doubles representing the parameters
-
getParameters
public final double[] getParameters()
Description copied from interface:ParametersIfcGets the parameters- Specified by:
getParametersin interfaceParametersIfc- Returns:
- Returns an array of the parameters
-
pmf
public final double pmf(double x)
Description copied from interface:PMFIfcReturns the f(x) where f represents the probability mass function for the distribution.
-
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
-
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
-
invCDF
public final double invCDF(double p)
Description copied from interface:InverseCDFIfcProvides 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:
invCDFin 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:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
-