Package jsl.utilities.distributions
Class Exponential
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.Exponential
-
- All Implemented Interfaces:
ControllableIfc
,CDFIfc
,ContinuousDistributionIfc
,DistributionFunctionIfc
,DistributionIfc
,DomainIfc
,FirstOrderLossFunctionIfc
,InverseCDFIfc
,LossFunctionDistributionIfc
,MeanIfc
,PDFIfc
,SecondOrderLossFunctionIfc
,VarianceIfc
,GetNameIfc
,IdentityIfc
,NewInstanceIfc
,ParametersIfc
,GetRVariableIfc
public class Exponential extends Distribution implements LossFunctionDistributionIfc, ContinuousDistributionIfc, InverseCDFIfc, GetRVariableIfc
Models exponentially distributed random variables This distribution is commonly use to model the time between events
-
-
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 Exponential()
Constructs a exponential distribution with mean 1.0Exponential(double mean)
Constructs a exponential distribution where mean is the mean of the distributionExponential(double[] parameters)
Constructs a exponential distributionwhere parameter[0] is the mean of the distributionExponential(double mean, java.lang.String name)
Constructs a exponential distribution where mean is the mean of the distribution
-
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 functiondouble
firstOrderLossFunction(double x)
Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]Interval
getDomain()
double
getKurtosis()
Gets the kurtosis of the distributiondouble
getMean()
Returns the mean or expected value of a distributiondouble
getMoment3()
double
getMoment4()
double[]
getParameters()
Gets the parametersRVariableIfc
getRandomVariable(RNStreamIfc rng)
double
getSkewness()
Gets the skewness of the distributiondouble
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.Exponential
newInstance()
Returns a new instancedouble
pdf(double x)
Returns the f(x) where f represents the probability density function for the distribution.double
secondOrderLossFunction(double x)
Computes the 2nd order loss function for the distribution function for given value of x, G2(x) = (1/2)E[max(X-x,0)*max(X-x-1,0)]void
setMean(double val)
Sets the mean parameter for the distributionvoid
setParameters(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
-
Methods inherited from interface jsl.utilities.distributions.VarianceIfc
getStandardDeviation
-
-
-
-
Constructor Detail
-
Exponential
public Exponential()
Constructs a exponential distribution with mean 1.0
-
Exponential
public Exponential(double[] parameters)
Constructs a exponential distributionwhere parameter[0] is the mean of the distribution- Parameters:
parameters
- A array containing the mean of the distribution, must be > 0.0
-
Exponential
public Exponential(double mean)
Constructs a exponential distribution where mean is the mean of the distribution- Parameters:
mean
- The mean of the distribution, , must be > 0.0
-
Exponential
public Exponential(double mean, java.lang.String name)
Constructs a exponential distribution where mean is the mean of the distribution- Parameters:
mean
- The mean of the distribution, , must be > 0.0name
- an optional label/name
-
-
Method Detail
-
newInstance
public final Exponential newInstance()
Description copied from interface:NewInstanceIfc
Returns a new instance- Specified by:
newInstance
in interfaceNewInstanceIfc
- Specified by:
newInstance
in classDistribution
- Returns:
- the new instance
-
setMean
public final void setMean(double val)
Sets the mean parameter for the distribution- Parameters:
val
- The mean of the distribution, must be > 0.0
-
getMean
public final double getMean()
Description copied from interface:MeanIfc
Returns the mean or expected value of a distribution
-
getMoment3
public final double getMoment3()
-
getMoment4
public final double getMoment4()
-
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.
-
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- Returns:
- the kurtosis
-
getSkewness
public final double getSkewness()
Gets the skewness of the distribution- Returns:
- the skewness
-
setParameters
public final void setParameters(double[] parameters)
Description copied from interface:ParametersIfc
Sets the parameters- Specified by:
setParameters
in interfaceParametersIfc
- Parameters:
parameters
- an array of doubles representing the parameters
-
getParameters
public final double[] getParameters()
Description copied from interface:ParametersIfc
Gets the parameters- Specified by:
getParameters
in interfaceParametersIfc
- Returns:
- Returns an array of the parameters
-
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
-
firstOrderLossFunction
public double firstOrderLossFunction(double x)
Description copied from interface:FirstOrderLossFunctionIfc
Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]- Specified by:
firstOrderLossFunction
in interfaceFirstOrderLossFunctionIfc
- Parameters:
x
- The value to be evaluated- Returns:
- The loss function value, E[max(X-x,0)]
-
secondOrderLossFunction
public double secondOrderLossFunction(double x)
Description copied from interface:SecondOrderLossFunctionIfc
Computes the 2nd order loss function for the distribution function for given value of x, G2(x) = (1/2)E[max(X-x,0)*max(X-x-1,0)]- Specified by:
secondOrderLossFunction
in interfaceSecondOrderLossFunctionIfc
- Parameters:
x
- The value to be evaluated- Returns:
- The loss function value, (1/2)E[max(X-x,0)*max(X-x-1,0)]
-
-